Between
c# version of "Between" clause of sql query
Source
public static bool Between<T>(this T value, T from, T to) where T : IComparable<T>
{
return value.CompareTo(from) >= 0 && value.CompareTo(to) <= 0;
}
Example
DateTime today = DateTime.Now;
var from = new DateTime(2012, 2, 1);
var to = new DateTime(2012, 12,20);
bool isBetween = today.Between(from, to);