Date Issues


I’m looking to get last week Monday and this week Sunday

I would appreciate any help.

Thank you


Welcome back to our UiPath community.

Previous week Monday:

             DateTime now = DateTime.Now
             int dayInWeek = (int)now.DayOfWeek
             DateTime previousMonday = now.AddDays(-(((dayInWeek + 6) % 7) + 7));

Current week Sunday:

              DateTime currentSunday = DateTime.Now.Subtract(new TimeSpan((int)DateTime.Now.DayOfWeek, 0, 0, 0))

I found the solution. thank you for the clue @lakshman

Now = DateTime.Now
Day_In_Week = DayOfWeek
CurrentSunday = DateTime.Now.Subtract(new TimeSpan(DateTime.Now.DayOfWeek,0,0,0))
PreviousMonday = CurrentSunday.AddDays(-6)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.