Start date and End Date

Hello,

How to enter the date for the previous month?
For exemple: Start date: 01/05/2020 and the End Date: 31/05/2020
Thank you in advance

1 Like

@Maryem_Karoui

for
last date = new DateTime(now.year,now.AddMonths(-1).Month, date.DaysInMonth(now.Year,now.AddMonths(-1).Month))

first date = new DateTime(now.year,now.AddMonths(-1).Month, 1)

2 Likes

Thank you so much

@Maryem_Karoui
Welcome, If it resolve your issue, mark it as answer.

StartDate = new DateTime(Now.AddMonths(-1).Year, Now.AddMonths(-1).Month,1)

EndDate = (new DateTime(Now.Year,Now.Month,1)).AddDays(-1)
1 Like

Your solution may be wrong for (2021/01/01)
last date = new DateTime(now.year,now.AddMonths(-1).Month, date.DaysInMonth(now.Year,now.AddMonths(-1).Month))

2 Likes

True, Thanks for correction :slight_smile:

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