Skip to content Skip to sidebar Skip to footer

Convert Epoch To Date In Sqlplus / Oracle

I have the following table: SQL> desc recording Name Null? Type -------------------- -------- ------ CAPTUREID NOT NULL NUMBER(9) STARTDATE

Solution 1:

In Oracle, adding X to a DATE will return you a DATE X days later.

If ESTIMATEDENDTIME is milliseconds since Epoch then you could do

DATE'1970-01-01'+ ( 1/24/60/60/1000) * ESTIMATEDENDTIME

and then use to_char to achieve the correct format of the resulting date. e.g:

SELECT 
  captureid
, startdate
, enddate
, state
, estimatedendtime
, DATE'1970-01-01'+ ( 1/24/60/60/1000) * estimatedendtime AS estimatedenddate
FROM recording

Solution 2:

select ((timestamp_coloum_name - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400)) from any_table;

Post a Comment for "Convert Epoch To Date In Sqlplus / Oracle"