Expression to return first day of previous month

Hello this expression I have
New DateTime(Now.Year,Now.Addmonths(-1).Month,1).ToString(“MM/dd/yy”)

returns “12/01/22”, but I need it to be the first day of the previous month “12/01/21”, can someone please help?

thanks so much in advance

2 Likes

Hello,
Maybe just add a condition and if your current month is 01 then sub 1 year to the result ?

Hi @lynnsong986 ,

Try the below Expression :

new DateTime(Now.AddMonths(-1).Year,Now.AddMonths(-1).Month,1).ToString("MM/dd/yy")

@lynnsong986

Check below for your reference

Thanks

You can use the below one.

LHS:FirstDayOfPreviousMnth
RHS:new DateTime(Date_Now.Year,Date_Now.Month,1).AddMonths(-1)

Thank you

1 Like

Thank you all for your kind help!

1 Like

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