SQL/MX 3.2 Reference Manual (H06.25+, J06.14+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Release 3.2 Reference Manual691117-001
9-47
Considerations for DATEDIFF
startdate, enddate
is of type DATE or TIMESTAMP.
Considerations for DATEDIFF
If startdate is later than enddate, the return value is either negative or zero.
If the result is out of range for integer values, an error is returned.
The maximum seconds datepart allowed is equivalent to 68 years.
If a difference in weeks is specified, and one of the two dates is earlier than
January 7, 0001, then an error is returned.
Return type
The result is a signed integer value equal to the number of datepart boundaries
crossed between the first and second date.
Examples of DATEDIFF
The following example illustrates the use of DATEDIFF function:
>>select dt_ts, dt_date, datediff(second, dt_ts, dt_date)
from T01;
DT_TS DT_DATE (EXPR)
-------------------------- ---------- -----------
2008-11-12 03:03:03.000000 2011-11-27 95893017
2112-01-30 09:05:00.000000 2112-01-30 -32700
--- 2 row(s) selected.
SECOND S and SS
QUARTER Q and QQ
WEEK WW and WK