Oracle / PLSQL: NUMTOYMINTERVAL Function

This article is written about how to use the Oracle/PLSQL NUMTOYMINTERVAL function with syntax and examples.

Description

The Oracle/PLSQL NUMTOYMINTERVAL function converts a number to an INTERVAL YEAR TO MONTH literal.

Syntax

The syntax for the NUMTOYMINTERVAL function in Oracle/PLSQL is:

NUMTOYMINTERVAL( number, expression )

Parameters or Arguments

number

The number to convert to an interval.

expression

The unit to convert to. It must be one of the following values: YEAR or MONTH.

Returns

The NUMTOYMINTERVAL function returns an INTERVAL YEAR TO MONTH value.

Applies To

The NUMTOYMINTERVAL function can be used in the following versions of Oracle/PLSQL:

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let’s look at some Oracle NUMTOYMINTERVAL function examples and explore how to use the NUMTOYMINTERVAL function in Oracle/PLSQL.

For example:

NUMTOYMINTERVAL(100000000, 'MONTH')
Result: '+0083'

NUMTOYMINTERVAL(100000, 'YEAR')
Result: '+0001'