C#: Get First or Last Day of this Month

Get First or Last Day of this Month using C#

C# Code Snippets

C#: Get First or Last Day of this Month

There are many ways to do this, I find these simple enough:

public static DateTime GetFirstDayOfMonth(DateTime thisDate)
{
  // return the first day of month of the date given.
  return new DateTime(thisDate.Year, thisDate.Month, 1);

}

public static DateTime GetLastDayOfMonth(DateTime thisDate)
{  // return the last day of month of the date given.
  return GetFirstDayOfMonth(thisDate).AddMonths(1).AddDays(-1);
}