Skip to main content

C# DataTime extension to check if it is on or between a specified start and end date.

public static bool IsOnOrBetweenDates(this DateTime self, DateTime startDate, DateTime endDate)
{
    return (self.Date >= startDate.Date && self.Date <= endDate.Date);
}