public DateTime GetLastDayPrevMonth(int month, int year) { return new DateTime(year, month, 1).AddDays(-1); // AddMonth(-1) for previous month }