Last date in current month

How to find the last date in current month ?

For example if today is 12/20/2019 then i need to find the last date in the month of december . It should be 12/31/2019.

Please help me

Hi @vamsi.battulaus008

Use Now.ToString.AddDays(-11).ToString(“MM/dd/yyyy”)

Thanks
Ashwin S

Hi,

The following might help you.

(New DateTime(Today.AddMonths(1).Year,Today.AddMonths(1).Month,1)).AddDays(-1)

or

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

Regards,

5 Likes

Hello @vamsi.battulaus008

You can use the following C# code in the assign activity to get the first and last day of the current month:

DateTime now = DateTime.Now;
var startDate = new DateTime(now.Year, now.Month, 1);
var endDate = startDate.AddMonths(1).AddDays(-1);

Hope this helps you.

@vamsi.battulaus008,

Try using DaysInMonth option as following

New DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month))
1 Like

New DateTime(cdate(date1).Year,cdate(date1).Month,DateTime.DaysInMonth(cdate(date1).Year,cdate(date1).Month))

Here Date1=“12/28/2019”

1 Like