Joseph Michael Pesch
VP Programming

C# Get First and Last Day of Previous Month

by 3. December 2012 08:25

To get the first day of previous month:

var firstDayPrevMonth = new DateTime(DateTime.Today.Year
  , DateTime.Today.Month, 1).AddMonths(-1);

To get the last day of previous month:

var lastDayPrevMonth = new DateTime(DateTime.Today.Year
  , DateTime.Today.Month, 1).AddDays(-1);

 

Tags:

C#

Comments are closed