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 or subtract a date and time value.

Syntax

TO_YMINTERVAL (years-months)

Parameters

Parameter

Description

years-months

The string of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type in compliance with the format of this parameter.

Return type

INTERVAL YEAR TO MONTH data type

Examples

The following example shows that the date and time value one year and two months later than the current time is returned:

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