This is how I currentyl get the first date of last month:
Frmdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
Frmdate.AddMonths(-1).ToString("dd/MM/yyyy");
The result is 01/01/2015
.
When I am in february:
ToDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
ToDate.AddMonths(-1).ToString("dd/MM/yyyy");
The result is 28/01/2015
, but I need 31/01/2015
.
I need a way to solve this only for the month of february.