All Products
Search
Document Center

TO_YMINTERVAL

Last Updated: Jun 18, 2021

The TO_YMINTERVAL function converts a string of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type to a value of the INTERVAL YEAR TO MONTH data type. You can use this function to add a time interval to or subtract a time interval from a datetime value.

Syntax

TO_YMINTERVAL (years-months)

Parameters

Parameter

Description

years-months

The string of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. The string must meet the format requirements of this parameter.

Return type

INTERVAL YEAR TO MONTH data type

Examples

In the following example, the statement returns a datetime value and the value indicates the date and time that is one year and two months later than the current time:

SELECT SYSDATE,SYSDATE+TO_YMINTERVAL('01-02') FROM DUAL;

The following query result is returned:

+---------------------+--------------------------------+
| SYSDATE             | SYSDATE+TO_YMINTERVAL('01-02') |
+---------------------+--------------------------------+
| 2020-03-08 22:32:01 | 2021-05-08 22:32:01            |
+---------------------+--------------------------------+