Sitecore date comparison doesn't return expected results

Viewed 728

I'm trying to return a list of courses using an iqueryable query but am having issues with some date comparisons.

I'm currently using the code

query = query.Where(r => r.EndDate >= DateTime.UtcNow);

which returns courses with dates in the future, however it will not return courses that end on the same day with a time ending later than the time returned by DateTime.UtcNow.

Any ideas what I am doing wrong?

I've just used Luke to check the index and if I use

end_date:[20170531t092205609z TO *]

I get back the exact results I need, however in the logs the actual query uses

+end_date:[20170531t092205609z TO *] +_template:a84b75fccac64eafa746f4b71e628adc - Filter : 

I then get more results back including the course I was missing.

a) Why do I get more results back using the second query?
b) Why is it that in my C# code the results returned do not match the search results?

1 Answers
Related