Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created July 7, 2015 03:14
Show Gist options
  • Select an option

  • Save christopherbauer/47720bd3888d134cba89 to your computer and use it in GitHub Desktop.

Select an option

Save christopherbauer/47720bd3888d134cba89 to your computer and use it in GitHub Desktop.
// Verify if a datetime is in a range
public static bool BetweenInclusive(this DateTime dateToCompare,
DateTime Left, DateTime Right)
{
bool result = (dateToCompare.CompareTo(Left) >= 0) &&
(dateToCompare.CompareTo(Right) <= 0);
return result;
}
// Verify if a datetime is in a range
public static bool BetweenExclusive(this DateTime dateToCompare,
DateTime Left, DateTime Right)
{
bool result = (dateToCompare.CompareTo(Left) > 0) &&
(dateToCompare.CompareTo(Right) < 0);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment