Skip to content

NUMTOYMINTERVAL

  • n: This is the first parameter of the NUMTOYMINTERVAL function, representing the number. It converts this numeric value into an “interval year to month” datatype.
  • ‘interval_unit’: This is the second parameter of the NUMTOYMINTERVAL function. It specifies the unit of the interval such as ‘YEAR’ or ‘MONTH’. The function uses this parameter to interpret the numeric value.
SELECT NUMTOYMINTERVAL(2, 'YEAR') FROM dual;
+------------------------+
| NUMTOYMINTERVAL(2,YEAR)|
+------------------------+
| +02-00 |
+------------------------+

The NUMTOYMINTERVAL function in Oracle SQL is used to convert a number to a year-month INTERVAL. In this example, the function converts the number 2 into an interval of 2 years. The output “+02-00” represents “2 years and 0 months”.