Convert epoch to date in sqlplus / Oracle

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

Leave a Comment