Definition: |
include builtins\timedate.e
atom a = timedate_diff(timedate td1, timedate td2, integer term=0) |
Description: |
Returns the difference in seconds between two dates. A positive value is returned when td1 is before td2.
A term of DT_SECOND, DT_MINUTE, DT_HOUR, DT_DAY, DT_MONTH, or DT_YEAR may be supplied to truncate the difference to a whole number of that period (see example below). Note that DT_MONTH is treated as 30 days, and DT_YEAR uses 365.25 to calculate the whole number of years, but then multiplies by 365 to get back to seconds. If term is zero (the default) then no such rounding is attempted. |
Comments: |
As with timedelta, the result is intended to be used as a parameter to
adjust_timedate(), and it can also be supplied as an argument to
elapsed().
Note that results from date() should either have been generated with bMsecs:=true or have their [DT_MSEC] entries set to zero before being passed to timedate_diff(). |
Example: |
include builtins\timedate.e timedate birthdate = parse_date_string("1/1/1960",{"D/M/YYYY"}) printf(1,"You are %s old\n",{elapsed(timedate_diff(birthdate,date(),DT_DAY))}) -- displays "You are 57 years, 304 days old" |
See Also: | timedate, adjust_timedate, parse_date_string, elapsed |