Wednesday, May 1, 2013

Convert Seconds to Date/timespamp in oracle


 Convert Seconds to Date in oracle

            If user has number between 00 to 59,That number can be converted to timestamp .

Syntax:
           to_timestamp(seconds,fmt)  
        



SQL> select to_timestamp('00','ss') from dual;

to_timestamp('00','ss')
-------------------------------------------------
01-MAY-14 12.00.00.000000000 PM
 
It has current date, time specified in the format.
 
SQL> select to_timestamp('59','ss') from dual;

to_timestamp('59','ss')
-----------------------------------------------
01-MAY-13 12.00.59.000000000 AM




If seconds is not between 00 and 59
  following error message will be displayed.


ERROR at line 1:
ORA-01851: seconds must be between 0 and 59
 

Tags: Convert seconds      to date/timestamp,convert seconds      to Date/timestamp using To_timestamp function,oracle convert seconds      to date ,oracle convert seconds      to date/timestamp using to_date,oracle convert seconds      to current seconds     date/timestamp.

No comments:

Post a Comment