Need help to get Monday date of every week

Hi Team,

I have a requirement to access the file which has the date in filename. That file generates every week on Monday. So, when my bot is running any day of the week, I should train my bot to access the latest Monday date file. Can anyone help with how to get the latest Monday date into variable?

Thanks,
Divya.

One of many options:
grafik

myDate | DateTime

myDate.AddDays( - {6,0,1,2,3,4,5}(myDate.DayOfWeek))

we had configured an Array with the offset of days we want to get back to the week’s monday
with the DayOfWeek (0=Sunday, 1=Monday,6=Sunday) we select the offset as needed

When we do have other rules e.g. on Monday get Monday of previous week … then we just modify the array with the offsets

with AddDays( - CalculatedOffset) we retrieve the Monday of the Week of myDate

@divya.x.kuchi
Hello, there are many ways to do this, but one is to:
Assign activity: CurrentDate = DateTime.Now
Assign activity: Day = DateTime.Now.DayOfWeek.ToString
Else If activity (you will need 6 of these): Condition: Day = “Monday”
Assign activity: GetMonday = CurrentDate
Tuesday will be -2
Wednesday will be -3…so on

Final Else will be: Assign activity: GetMonday = CurrentDate.AddDays(-6)

CurrentDate is DateTime type
Day is String type
GetMonday is DateTime type

Regards

Just to add: @ppr way is much simpler

A helpful activity you can also use:

image

Hi @ divya.x.kuchi
Use this one
strMonday=DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek .Monday)) mod 7).Date.ToString()

Regards,
mohini