NUMTOYMINTERVAL
NUMTOYMINTERVAL(n, ‘interval_unit’)
Section titled “NUMTOYMINTERVAL(n, ‘interval_unit’)”- 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.
Example
Section titled “Example”SELECT NUMTOYMINTERVAL(2, 'YEAR') FROM dual;Output
Section titled “Output”+------------------------+| NUMTOYMINTERVAL(2,YEAR)|+------------------------+| +02-00 |+------------------------+Explanation
Section titled “Explanation”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”.