Convert number to an interval year to month literal in oracle using NUMTOYMINTERVAL function

By Santhosh N

This explains how to convert the given number to the interval year to the month literal in oracle

There is a conversion function in oracle by the name, NUMTOYMINTERVAL which converts the specified number to the interval year to the month literal.

Syntax: NUMTOYMINTERVAL(n, expression)

Here n is the number that needs to be converted to an interval and expression is the unit which can be either YEAR or MONTH.

Ex1: SELECT NUMTOYMINTERVAL(12, 'MONTH') FROM dual;
This returns “+01-00” as result

Ex2: SELECT NUMTOYMINTERVAL(23, 'MONTH') FROM dual;
This returns “+01-11” as result

Ex3: SELECT NUMTOYMINTERVAL(12, 'YEAR') FROM dual;
This returns “+12-00” as result

Ex4: SELECT NUMTOYMINTERVAL(0.50, 'YEAR') FROM dual;
This returns “+00-06” as result

Related FAQs

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 given number to the interval (which can be days, hours, minutes, or seconds) in the oracle using the NUMTODSINTERVAL conversion function
This explains how to convert the bit vector to a number in the oracle using the BIN_TO_NUM conversion function.
This explains how to convert the the given date or integer values to strings.
This explains how to convert the string to date format in oracle.
This explains how to convert the timestamp value to the timestamp with time zone in oracle.
Convert number to an interval year to month literal in oracle using NUMTOYMINTERVAL function  (2018 Views)