CSharp examples for System:DateTime Calculate
Determines whether the specified start date is between.
using System.Globalization; using System;// w ww. j a v a 2s . co m public class Main{ /// <summary> /// Determines whether the specified start date is between. /// </summary> /// <param name="input">The input.</param> /// <param name="startDate">The start date.</param> /// <param name="endDate">The end date.</param> /// <param name="compareTime">if set to <c>true</c> [compare time].</param> /// <returns></returns> public static bool IsBetween(this DateTime input, DateTime startDate, DateTime endDate, bool compareTime = false) { return compareTime ? input >= startDate && input <= endDate : input.Date >= startDate.Date && input.Date <= endDate.Date; } }