DEV Community

[Comment from a deleted post]
Collapse
 
nickstavrou profile image
NickStavrou • Edited

You explicitly used

between '2018-01-01 00:00:00:000' and '2018-12-31 00:00:00:000'

in your query but it makes it error prone if your datetime isnt as accurate in milliseconds as you shown. You should better use for example:

(Your predicate) >= 2018-01-01 and < 2018-12-31

and this will guaranty that it will only take all the rows from the start and only the rows till the end.
So always use an open-ended range to prevent erroneously including or excluding rows. It’s much less complex to find the beginning of the next period than the end of the current period.