Oracle NUMTODSINTERVAL Function


/ Published in: SQL
Save to your folder(s)

A few examples of the NUMTODSINTERVAL function.


Copy this code and paste it in your HTML
  1. --Example 1
  2. SELECT NUMTODSINTERVAL(14, 'DAY')
  3. FROM dual;
  4.  
  5. --Example 2
  6. SELECT NUMTODSINTERVAL(6, 'HOUR')
  7. FROM dual;
  8.  
  9. --Example 3
  10. SELECT NUMTODSINTERVAL(32, 'HOUR')
  11. FROM dual;
  12.  
  13. --Example 4
  14. SELECT NUMTODSINTERVAL(25, 'MINUTE')
  15. FROM dual;
  16.  
  17. --Example 5
  18. SELECT NUMTODSINTERVAL(412, 'MINUTE')
  19. FROM dual;
  20.  
  21. --Example 6
  22. SELECT NUMTODSINTERVAL(51, 'SECOND')
  23. FROM dual;
  24.  
  25. --Example 7
  26. SELECT NUMTODSINTERVAL(8941564, 'SECOND')
  27. FROM dual;
  28.  
  29. --Example 8
  30. SELECT NUMTODSINTERVAL(16.265497, 'SECOND')
  31. FROM dual;
  32.  
  33. --Example 9
  34. SELECT NUMTODSINTERVAL(-18, 'HOUR')
  35. FROM dual;
  36.  
  37. --Example 10
  38. SELECT
  39. NUMTODSINTERVAL(8941564.59401,'SECOND') AS original_value,
  40. TO_CHAR
  41. ( LPAD(EXTRACT(DAY FROM elapsed_interval),3,'0')||' '||
  42. LPAD(EXTRACT(HOUR FROM elapsed_interval),2,'0')||':'||
  43. LPAD(EXTRACT(MINUTE FROM elapsed_interval),2,'0')||':'||
  44. LPAD(EXTRACT(SECOND FROM elapsed_interval),8,'0')
  45. ) AS formatted_seconds
  46. FROM (
  47. SELECT numtodsinterval(8941564.59401,'SECOND') AS elapsed_interval
  48. FROM dual
  49. );

URL: http://www.databasestar.com/oracle-numtodsinterval/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.