ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

BeginningOfTheMonth

Returns datetime corresponding to first day of the month

Source

public static DateTime BeginningOfTheMonth(this DateTime date)
{
	return new DateTime(date.Year, date.Month, 1);
}

Example

var firstDay = DateTime.Now.BeginningOfTheMonth();

Author: Victor Rodrigues

Submitted on: 13 mei 2009

Language: C#

Type: System.DateTime

Views: 5457