Ok this is kinda a messy query and I am only having limited success with it. I have a list of a Foo class that has a datetime property and other data. I have a class/row for allmost every minute, with some missing and some entire days missing like a holiday or weekend. My goal is to group each day for all rows from a start time to an end time.
So on some days my start time may be 9:30am and endtime 3:00pm. This situation I handle by the following:
DateTime sd = new DateTime(2000, 1, 1, 9, 30, 0);
DateTime ed = new DateTime(2000, 1, 1, 15, 0, 0);
var z = Foos.Where(a=> a.FooDate.TimeOfDay >= sd.TimeOfDay &&
a.FooDate.TimeOfDay < ed.TimeOfDay)
.GroupBy(a=>a.FooDate.Date);
This works fine. My problem is sometimes I have a starttime of 9pm and a endtime of 6am. In that case i want the group of foos to go overnight, and if the 9pm is on a friday and there are no rows till the next monday i want the the group to span the weekend. I would even be happy with a suggestion of a query that would just allways go to the next day.
I hope thats clear and appreciate any ideas. I tried alot of other ways to do this with loops and creating another list of distinct dates and such but am not happy with it.