GetLastDayOfMonth

public static DateTime GetLastDayOfMonth(this DateTime dateTime)
{
    return new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1).AddDays(-1);
}
Example:
DateTime lastDay = DateTime.Now.GetLastDayOfMonth();

Description

Gets the last date of the month of the DateTime.

Details

Double click on the code to select all.

 

;