in my database a have rows like
And in my Blazor app i need to find the match if the clock is 15 minutes before TimeStart AND 15 minuttes before TimeEnd.
If the clock is between 9.45 and 10.45 I want RowID 27
If the clock is between 10.45 and 11.45 I want RowID 28
I have tried:
IEnumerable<Overview> mydata = from a in overview
where (a.Timestart > Minus15Min &&
a.Timeend.Value.Subtract(new TimeSpan(00, 15, 00)) > Minus15Min)
select a;
CodePudding user response:
Your problem is very symmetrical about Start and End but your code treats them differently. Also, you have two >
for a range, that is very doubtful.
How about
var nowPlus15 = DateTime.Now.AddMinutes(15);
IEnumerable<Overview> mydata = from a in overview
where (a.Timestart <= nowPlus15 &&
a.Timeend > nowPlus15)
select a;