Skip to content

Instantly share code, notes, and snippets.

@mbalex99
Created September 18, 2013 20:39
Show Gist options
  • Save mbalex99/6615326 to your computer and use it in GitHub Desktop.
Save mbalex99/6615326 to your computer and use it in GitHub Desktop.
DateTime Range Query
var rangeStart = new DateTime(2012, 1, 1);
var rangeEnd = new DateTime(2012, 12, 31);
var res = list
.Where(item => (item.StartTime < rangeStart ? rangeStart : item.StartTime) < (item.EndTime < rangeEnd ? item.EndTime : rangeEnd) )
.ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment