TO_YMINTERVAL converts a text expression to an INTERVAL YEAR TO MONTH data type. The function accepts argument in one of the two formats:
SQL interval format compatible with the SQL standard (ISO/IEC 9075:2003)
ISO duration format compatible with the ISO 8601:2004 standard
INTERVAL YEAR TO MONTH
TO_YMINTERVAL ( ' { sql_format | ym_iso_format } ' ) sql_format::= [+|-] years - months ym_iso_format::= [-] P [ years Y ] [months M ] [days D ] [ T [hours H ] [minutes M ] [seconds [. frac_secs] S ] ]
In SQL format:
years is an integer between 0 and 999999999
months is an integer between 0 and 11.
Additional blanks are allowed between format elements.
In ISO format:
years and months are integers between 0 and 999999999.
days, hours, minutes, seconds, and frac_secs are nonnegative integers and are ignored.
No blanks are allowed in the value.
TO_YMINTERVAL('1-6') and TO_YMINTERVAL('P1Y6M') return the value +01-06 for 1 year and 6 months.
SYSDATE + TO_YMINTERVAL('1-6') adds one year and six months to the current date. When SYSDATE is 15-APR-08, the value is 15-OCT-09.
SYSDATE + TO_YMINTERVAL('P1Y6M') adds one year and six months to the current date using ISO format. When SYSDATE is 15-APR-08, the value is 15-OCT-09.
SYSDATE + TO_YMINTERVAL('-1-2') subtracts one year and two months from the current date. When SYSDATE is 15-APR-08, the value is 15-FEB-07.