Quote:
Incorrect:
select CURRENT DATE + 30 DAYS - CURRENT DATE FROM SYSIBM.SYSDUMMY1
1
----------
100.
|
No!
This is what is expected.
It means 1 month 0 day.
SQL Reference Volume 1 ---> Chapter 2. Language elements ---> Expressions ---> Datetime operations and durations ---> Date arithmetic:
The result of subtracting one date (DATE2) from another (DATE1) is a date duration that specifies the number of years, months, and days between the two dates. The data type of the result is DECIMAL(8,0).
Code:
------------------------------ Commands Entered ------------------------------
SELECT CURRENT DATE
, CURRENT DATE + 30 DAYS
, CURRENT DATE + 30 DAYS - CURRENT DATE
FROM SYSIBM.SYSDUMMY1;
------------------------------------------------------------------------------
1 2 3
---------- ---------- ----------
2009-09-07 2009-10-07 100.
1 record(s) selected.