How to get previous month last date

How to get previous month last date

current date 2020-02-27
previous month date 2020-01-31

Hi,

Hope the following expression helps you.

new DateTime(now.Year,now.Month,1).AddDays(-1)

Regards,

Hi @Yoichi

I need remove time 00:00:00 I need only month and year

2

Hi,

Can you try the following?

New DateTime(now.Year,now.Month,1).AddDays(-1).toString("MM/dd/yyyy")

Regards,

2 Likes

Hi @DinukaThilakarathne,

if only previous month and year needed then use
Datetime.Today.addmonth(-1).month.tostring - for month
Datetime.Today.addmonth(-1).year.tostring - for year

Regards
Shanmukh

3 Likes

Hi @Yoichi, @shanmukh_pothamsetty,

Thank you very much. My issue is clear now.

Regard.

1 Like

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