Skip Headers
Oracle® OLAP Expression Syntax Reference
Release 11.2

E23381-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

TO_YMINTERVAL

TO_YMINTERVAL converts a text expression to an INTERVAL YEAR TO MONTH data type. The function accepts argument in one of the two formats:

Return Value

INTERVAL YEAR TO MONTH

Syntax

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  ] ]

Arguments

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.

Examples

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.