Convert string to an interval Year to Month type in oracle using TO_YMINTERVAL function

By Santhosh N

This explains how to convert the string to an interval Year to Month type in oracle.

There is a conversion function in oracle by the name, TO_YMINTERVAL which converts the specified string to an interval Year to Month type in oracle.

Syntax: TO_YMINTERVAL(char)

Here char is the value of the string that needs to be converted and it can be a char, varchar2, nchar or nvarchar2 type value.

Ex1: SELECT TO_YMINTERVAL('05-05') FROM dual;
This returns “+05-05” as result

Ex2: SELECT TO_YMINTERVAL('0-11') FROM dual;
This returns “+00-11” as result

Note: Maximum month value allowed is 11.

Related FAQs

This explains how to convert the string to an interval Day to Second type in oracle.
This explains how to convert the given number to the interval year to the month literal in oracle
This explains how to convert the given number to the interval (which can be days, hours, minutes, or seconds) in the oracle using the NUMTODSINTERVAL conversion function
Use Oracle TO_NUMBER to convert a string to a number and format the number in the desired nls language.
This explains how to convert the the given date or integer values to strings.
This explains how to convert LOB value to NCLOB value in oracle.
Convert string to an interval Year to Month type in oracle using TO_YMINTERVAL function  (1252 Views)