4 ms·
Huh? 23:59:59 is neither, it's one second early.
by rhn_mk1 4y ago
Huh? 23:59:59 is neither, it's one second early.
- wongarsu 4y agoI think that's the point, people insist on using 23:59:59 as end of day instead of the correct 24:00:00 (which happens to be the same instant as 00:00:00 of the next day, since there's no gap between days)
- twawaaay 4y agoMy working theory on why this happens is that there are two different models and people sometimes have problem choosing the correct one. When you say "Thursday" you mean entire 24h period. It is not a point in time, it is a label for a span of time. But when you say "1 pm" you don't mean an entire hour, you mean a point in time that is more or less precisely 1pm. It seems people extend the first model to a lot of cases where it is not correct. And so for many people their mental model of 23:59:59 is a label for a span of time that is one second in length. If your model is that a day consists of 86400 "seconds", each second being a span of time of length of one second with a label like 12:37:28, then 23:59:59 is the last second of the day and 00:00:00 is the first second of the next day.
- rhn_mk1 4y agoWorking with spans is fraught with peril, though. It invites off-by-one errors. If there's one person in the queue to the checkout, then span-wise, that person is the start of the queue and the end of the queue. But if the start and end are the same, what is the length of the queue? (If you still insist it's one, you'll not be able to answer the question where the start and end of an empty queue is. There is no first or last person!)
- jl6 4y agoFun fact, ISO 8601 used to allow 24:00:00 notation (as a synonym of 00:00:00), but in the latest version of the standard it does not.
- emsixteen 4y agoHonest question, what are you supposed to do instead?
- twawaaay 4y agoYou add 1 day (not 24 hours) to beginning of day. If you have a good library it should handle it correctly.
- greenshackle2 4y ago> 1 day (not 24 hours) Just to spell it out, some days have 25 hours or 23 hours due to daylight savings, or 24 hours and 1 second because of leap seconds, etc.
- noSyncCloud 4y agoNot understanding this complaint. ```TSQL select cast('2022-07-12 24:00:00' as datetime) ``` >>> The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. ```python from datetime import datetime d: datetime = datetime(2022, 7, 12, 24, 0, 0) ``` >>> ValueError: hour must be in 0..23
- deleted 4y ago[deleted]
- jhgb 4y agoWell you clearly can't use 24:00:00 universally as the end of your day because sometimes there's a 24:00:01 on some days?
- throwaway294566 4y agoYou can. The leap second is always 23:59:60
- jhgb 4y agoYep, I may have forgotten about that. Shame on me.