Unix Timstamps in SQL

by Wolfram Saringer  (2014-01-27)
last change: 2014-01-27


Convert a Unix timestamp to a Date in Oracle 11g:

SELECT to_date('1970-01-01','YYYY-MM-DD') + numtodsinterval(1390828626,'SECOND') FROM dual;

Be careful: this seems to be off by 1h.


And on Postgres:
SELECT (TIMESTAMP WITH TIME ZONE 'epoch' + unix_tstamp * INTERVAL '1 second')::date


all articles represent the sole opinion of their respective author. all content comes without any warranty for correctnes, despite due diligence.