Change
DateTime toGrab = DateTime.Now.AddMinutes(10) .AddSeconds(-DateTime.Now.Second) .AddMilliseconds(-DateTime.Now.Millisecond);
For
DateTime now = DateTime.Now; DateTime toGrab = now.AddMinutes(10) .AddSeconds(-now.Second) .AddMilliseconds(-now.Millisecond);
In another note, is there a reason you would need to schedule an appointment for the exact millisecond? Does he seem very prone to missing entries?
Edit
In addition, in your database, the value 2015-12-10 10:33:48.373 differs from 2015-12-10 10:33:48.374 , although they are at a distance of 1 millisecond. If you want a wider range, you can do c.StartDate >= startDate && c.StartDate <= endDate && c.Approved == 1
Shaun sharples
source share