totn Oracle Functions

Oracle / PLSQL: NUMTODSINTERVAL Function

This Oracle tutorial explains how to use the Oracle/PLSQL NUMTODSINTERVAL function with syntax and examples.

Description

The Oracle/PLSQL NUMTODSINTERVAL function converts a number to an INTERVAL DAY TO SECOND literal.

Syntax

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

NUMTODSINTERVAL( 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: DAY, HOUR, MINUTE, or SECOND.

Returns

The NUMTODSINTERVAL function returns an INTERVAL DAY TO SECOND value.

Applies To

The NUMTODSINTERVAL 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 NUMTODSINTERVAL function examples and explore how to use the NUMTODSINTERVAL function in Oracle/PLSQL.

For example:

NUMTODSINTERVAL(150, 'DAY')
Result: '+000000150'

NUMTODSINTERVAL(1500, 'HOUR')
Result: '+000000062'

NUMTODSINTERVAL(15000, 'MINUTE')
Result: '+000000010'

NUMTODSINTERVAL(150000, 'SECOND')
Result: '+000000001'