IsBetween

public static Boolean IsBetween(this DateTime dt, DateTime startDate, DateTime endDate, Boolean compareTime = false)
{
   return compareTime ?
      dt >= startDate && dt <= endDate :
      dt.Date >= startDate.Date && dt.Date <= endDate.Date;
}
Example:
var today = DateTime.Now;
var start = new DateTime(2012, 1, 1);
var end = new DateTime(2013, 11, 25);

Boolean isBetween = today .IsBetween(start, end);

Description

Checks if the date is between the two provided dates

Details

Double click on the code to select all.

 

;