3 ms·
Honestly, it's simpler than that. Instead of doing <= for your end time, simply say <. That is, give me events where time >=30/1/2020 00:00:00 and time < 31/1/
by pwagland 6y ago
Honestly, it's simpler than that. Instead of doing <= for your end time, simply say <.
That is, give me events where time >=30/1/2020 00:00:00 and time < 31/1/2020 00:00:00.
- willis936 6y agoTidy. Thanks. It needs an extra line to properly establish what the next day is, but this is much more robust. For a larger set of reasons related to how data is being stored, the base date variable is a string in format yyyyMMdd. dateNext = sprintf(‘%s’, datetime(date, ‘format’, ‘uuuuMMdd’) + days(1));
- lmilcin 6y agoYes, that is correct solution. You know what the problem is? The developer wants to have events (like trades, transactions, log lines, users signed up, etc.) from a particular day and for some reason they fear/dislike having the next day. For some reason the 31/1/2020 00:00:00 is bad so the will prefer 30/1/2020 23:59:59. I honestly don't know where this is coming from but it is real and I spend literally tens of hours trying to explain this to people, sometimes with no avail. Actually, I know where this is coming from. This is mistaken attempt at addressing the last second. How do you design system that filters stuff by giving range of dates? Go to any reservation system and you will see that to select just today, you need to select from=today and to=today instead of from=today and to=tomorrow. I think fundamentally, this is mental model that causes people to think about the time not as a continuum but rather in chunks of some unit. Depending on the type of event they will select best-matching unit (typically year, day, minute or second) and treat it as atomic with the timestamp of beginning of the time duration representing entire duration. So in those minds, 23:59:59 represents entire last second of the day and there is no problem. 00:00:00 would represent the first second of the next day and that would be a problem. Unfortunately, this is wrong mental model for things that happen on continuum of time or when somebody needs to block things using different units. It only really works for things that are really managed in blocks of a given unit. For example, I can understand specifying accounting date range as from 1st to 31st of the month. This is right. Accounting date is no date at all, it is a label for a set of events that through some rules were associated with the label.