public static class MonthExtensions { /// /// Gets the first day of the month. /// /// The given date. /// the first day of the month public static DateTime GetFirstDayOfMonth(DateTime givenDate) { return new DateTime(givenDate.Year, givenDate.Month, 1); } /// /// Gets the last day of month. /// /// The given date. /// the last day of the month public static DateTime GetTheLastDayOfMonth(DateTime givenDate) { return GetFirstDayOfMonth(givenDate).AddMonths(1).Subtract(new TimeSpan(1, 0, 0, 0, 0)); } }