Date manipulation and calculation

Hi
Can someone please guide me.
I have to select current date and then need the last day of month. after it minus it with last 5 month.
For example
todaysDate= 02.05.19
Last day of month=31.05.19
DateCalculations= 31.05.19 - 5months

todays date i have got it but dont know how to go further ? any help would be appreciated
@PrankurJoshi @richarddenton

Thanks

@bullah

Last Day of month:

new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year,now.Month)).ToShortDateString

LastDayOfMonth.AddMonths(-5).Tostring (“dd.MM.yy”)

1 Like

Thanks a lot @lakshman
Can you please guide me further how to minus previous 5 months from Last Day of month?

1 Like

Sorry i saw in detail now thank you so much

1 Like

@bullah

If the above solution works for you then close this thread by marking it as solution.


I think i am doing a mistake if you can guide me more like where i am going wrong? choosing the wrong variable type ? i have used System.DateTime as well string.
as i get it done will close the thread thanks for it

@bullah

Could you please go to that exclamation mark and show me error once.

this is correct one sorry

@bullah

Sorry. Try this:

new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year,now.Month))

3 Likes

Thanks a lot its working … Wish you good evening
:slight_smile:

1 Like

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