From 11.1 onwards with YEAR-TO-MONTH Interval function, oracle has supported the nominal duration (Year, Month ) with time format. However specifying time format doesn’t generate the result as expected. You can browse the document describing this behavior here.
From my 10g sandbox, this function supports only nominal duration. Using ISO 8601 standard, you don’t have to specify a month except for ISO/IEC 9075, otherwise the error appears (ORA-1867: the interval is invalid)
10g> select sysdate
, sysdate + TO_YMINTERVAL('10-0') ISO_IEC_9075_2003
, sysdate + TO_YMINTERVAL('P10Y') ISO_8601_2004
from dual;
SYSDATE ISO_IEC_9075_2003 ISO_8601_2004
-------------------- -------------------- --------------------
26-SEP-2016 10:33:36 26-SEP-2026 10:33:36 26-SEP-2026 10:33:36
ISO/IEC 9075 2003 doesn’t support a TIME format. except you switch to use ISO 8601 format. This example shows you if you need to add 1 HOUR ahead
10g> select sysdate
, sysdate + TO_YMINTERVAL('10-0') ISO_IEC_9075_2003
, sysdate + TO_YMINTERVAL('P10YT1H') ISO_8601_2004
from dual;
ERROR at line 3:
ORA-01867: the interval is invalid
As oracle’s note on document 10g, it doesn’t support TIME format until 11.1 version.
11g> select sysdate
, sysdate + TO_YMINTERVAL('10-0') ISO_IEC_9075_2003
, sysdate + TO_YMINTERVAL('P10YT1H') ISO_8601_2004
from dual;
SYSDATE ISO_IEC_9075_2003 ISO_8601_2004
-------------------- -------------------- --------------------
26-SEP-2016 10:39:06 26-SEP-2026 10:39:06 26-SEP-2026 10:39:06
You’d be noticed that even if you add more 1 hour, but the result of this function is NOT completely certified with ISO yet. The latest version 12.1 when writing on this blog remains the same.
12c> select sysdate
, sysdate + TO_YMINTERVAL('10-0') ISO_IEC_9075_2003
, sysdate + TO_YMINTERVAL('P10YT1H') ISO_8601_2004
from dual;
SYSDATE ISO_IEC_9075_2003 ISO_8601_2004
-------------------- -------------------- --------------------
26-SEP-2016 10:43:49 26-SEP-2026 10:43:49 26-SEP-2026 10:43:49