Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL NUMTODSINTERVAL Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: NUMTODSINTERVAL

Definition:
The Oracle PL/SQL NUMTODSINTERVAL function converts an input number to its specified Interval Day to Second Unit equivalent. The allowed interval units can be DAY, HOUR, MINUTE, or SECOND. The return type of the function is INTERVAL.

Example Syntax:

NUMTODSINTERVAL(n, interval unit)


Note that the interval unit is case insensitive.

Example Usage:

The SQL queries below show the output for conversion of numeric value 1 into provided Interval units.

SQL> SELECT NUMTODSINTERVAL(1,'DAY') FROM DUAL;

NUMTODSINTERVAL(1,'DAY')
---------------------------------------------------------------------
+000000001 00:00:00.000000000

SQL> SELECT NUMTODSINTERVAL(1,'HOUR') FROM DUAL;

NUMTODSINTERVAL(1,'HOUR')
---------------------------------------------------------------------
+000000000 01:00:00.000000000

SQL> SELECT NUMTODSINTERVAL(1,'MINUTE') FROM DUAL;

NUMTODSINTERVAL(1,'MINUTE')
---------------------------------------------------------------------
+000000000 00:01:00.000000000

SQL> SELECT NUMTODSINTERVAL(1,'SECOND') FROM DUAL;

NUMTODSINTERVAL(1,'SECOND')
---------------------------------------------------------------------
+000000000 00:00:01.000000000


SQL> SELECT NUMTODSINTERVAL(1,'MONTH') FROM DUAL;
SELECT NUMTODSINTERVAL(1,'MONTH') FROM DUAL;
*
ERROR at line 1:
ORA-01760: illegal argument for function



Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 253 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?