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


Return the first day of the mounth for a given date


public static DateTime FirstDayOfMonth(this DateTime value)
   return new DateTime(value.Year, value.Month, 1);


var date = new DateTime(2023, 01, 30);

int firstDay = date.FirstDayOfMonth();

Author: Fernando Sarturi Prass

Submitted on: 30 jan. 2023

Language: csharp

Type: System.DateTime

Views: 1696