EndOfTheMonth

public static DateTime EndOfTheMonth(this DateTime date)
{
	var endOfTheMonth = new DateTime(date.Year, date.Month, 1)
		.AddMonths(1)
		.AddDays(-1);

	return endOfTheMonth;
}
Example:
var lastDay = DateTime.Now.EndOfTheMonth();

Description

Returns datetime corresponding to last day of the month

Details

Double click on the code to select all.

 

;