Difference between two dates.
-
Hi
I need to identify the difference between the two dates, to have in the example below the information that is in FINAL.
Is there a function, or an easier way to get the DateDiff object, without having to do all the DifDAY, DifHOUR, and DifMIN calculations first?
Date1 = 11/15/2021 15:35:00 timestamp 1637008500000
Date2 = 12/25/2021 17:55:00 timestamp 1640472900000@therealdb this is the case that I commented to you by message.
@toggledbits would there be a function for this? I imagined something like a diffdateparts([time1], [time2]) function, a plagiarism of the dateparts() function
Thanks.
-
Hi
I need to identify the difference between the two dates, to have in the example below the information that is in FINAL.
Is there a function, or an easier way to get the DateDiff object, without having to do all the DifDAY, DifHOUR, and DifMIN calculations first?
Date1 = 11/15/2021 15:35:00 timestamp 1637008500000
Date2 = 12/25/2021 17:55:00 timestamp 1640472900000@therealdb this is the case that I commented to you by message.
@toggledbits would there be a function for this? I imagined something like a diffdateparts([time1], [time2]) function, a plagiarism of the dateparts() function
Thanks.
I'm still trying to try one of these things and not have @toggledbits come in right behind me and show a much easier way. Maybe this time I'll get lucky.
-
I'm still trying to try one of these things and not have @toggledbits come in right behind me and show a much easier way. Maybe this time I'll get lucky.
@alan_f said in Difference between two dates.:
Maybe this time I'll get lucky.
That's not luck, that's experience. It's perfection. Great choice using the mod
%
operator.I haven't seen much need to provide a
datediff()
because the math is straightforward for the demands of most problems (delta times in seconds is probably the most common usage, with days, hours, and minutes being the second-most common but relatively infrequent by a wide margin). Having such a function would require the result to be returned in several different forms (likedateparts()
) to give the flexibility in response required, necessitating an object for the return value with keys (likedateparts()
). The added complexity of handling the returned object probably adds unnecessary bulk to the end-user's expressions that, weighed against the simple math of doing it yourself, isn't a good trade-off in my view. It also sets the stage for requesting some non-trivial parts be computed and returned: weeks? months? years? We get into big effects of leap seconds, leap days in leap years, and DST changes. Very hard to get right for all applications (widely varied in the minds of the end-user), and understand the side effects those exceptions create, know they exist, and handle them. And that also means a lot of extra computation when in most cases only a part of the response is needed. That's all just my opinion. I'm prepared to listen to arguments to the contrary. -
I'm still trying to try one of these things and not have @toggledbits come in right behind me and show a much easier way. Maybe this time I'll get lucky.
@alan_f very good! Nothing like consulting those who know how to use the available functions! Thank you very much, I am already removing what I had done and changing it to your instruction, and putting one more command in my knowledge notebook. Thank you very much!
-
T toggledbits locked this topic on