Oracle NUMTOYMINTERVAL Function

SQL NUMTOYMINTERVAL FunctionOracle NUMTOYMINTERVAL Function is used to convert any number to an Interval Year to Month Literal.


Oracle NUMTOYMINTERVAL Function Syntax

SELECT NUMTOYMINTERVAL(number,expression)
FROM table_name;
  • ‘number’ is the number to be converted to interval
  • ‘expression’ is the unit and can have the following values: ‘YEAR’ or ‘MONTH’

Oracle NUMTOYMINTERVAL – Converting to MONTH Example

Oracle NUMTOYMINTERVAL is used in SQL SELECT Statement to convert any number to an Interval Year to Month Literal.

For example, the below SQL Query converts 300000000 to MONTH.

SELECT NUMTOYMINTERVAL(300000000, 'MONTH')
FROM DUAL;

May return “+25000000-00”


Oracle NUMTOYMINTERVAL – Converting to YEAR Example

NUMTOYMINTERVAL can convert any number to an Interval Year type also.

For example, the below SQl Query converts 300000 to YEAR.

SELECT NUMTOYMINTERVAL(300000, 'YEAR')
FROM DUAL;

May return “+300000-00”


Tagged , , , , , , , , , , , . Bookmark the permalink.