How to get last Monday of pervious month

Hi ,

can anybody help me to get the last Monday of the previous month.

sure please find the code attached for reference @Shirin_Sebatina
Monday_Lastmonth.zip (1.6 KB)

1 Like

Hi,

Can you try the following expression?

dateTimeVar = Enumerable.Range(-7,7).Select(Function(i) New DateTime(Today.Year,Today.Month,1).AddDays(i)).Where(Function(d) d.DayOfWeek=DayOfWeek.Monday).First()

Regards,

Hi @Yoichi

I am getting this error

Hi,

Do you define variable named Today in your variable panel?
If so, the above expression refers not Datetime.Today but your variable. For now, can you try the following?

dateTimeVar = Enumerable.Range(-7,7).Select(Function(i) New DateTime(DateTime.Today.Year,DateTime.Today.Month,1).AddDays(i)).Where(Function(d) d.DayOfWeek=DayOfWeek.Monday).First()

OR

dateTimeVar = Enumerable.Range(-7,7).Select(Function(i) New DateTime(Now.Year,Now.Month,1).AddDays(i)).Where(Function(d) d.DayOfWeek=DayOfWeek.Monday).First()

Regards,

Hi @Yoichi

Yeah, there was variable in my variable panel ,
I removed it , it worked.

Thankyou

hey did u try out my code @Shirin_Sebatina if it doesnt work let me know

Hi @nikhil.girish

yes even your code worked.

1 Like

so @Shirin_Sebatina
kindly close this topic and mark any one as solution so that it will be benefitted to other forum members

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