Oracle Milliseconds to Date

Nov 28, 2016 / Updated on Nov 28, 2016

Seconds to Date:

SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(<<seconds>>, 'SECOND')
FROM dual;

e.g.

SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(1480340561, 'SECOND')
FROM dual;

Milliseconds to Date: Just divide the millseconds my 1000 so it will become seconds and apply the same query as above.

SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(<<milliseconds>>/1000, 'SECOND')
FROM dual;

e.g.

SELECT to_timestamp('1970-01-01','yyyy-mm-dd') + numtodsinterval(1480340490930/1000, 'SECOND')
FROM dual;
comments powered by Disqus
Categories:
Tags: