TO_YMINTERVAL

TO_YMINTERVAL is an Oracle SQL function that converges a character string representing an interval of years or months and returns an INTERVAL YEAR TO MONTH type.

Example

SELECT TO_YMINTERVAL('02-05') FROM DUAL;

Output

+-------------------+
| TO_YMINTERVAL('02-05') |
+-------------------+
| +02-05 |
+-------------------+

Explanation

The TO_YMINTERVAL function converts a string of YYYY-MM format into an INTERVAL YEAR TO MONTH literal. In the given query, ‘02-05’ is transformed to an interval of 2 years and 5 months. It returns the equivalent INTERVAL YEAR TO MONTH value.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.