Thursday, June 21, 2012

Oracle SQL Query to print Unix Timestamp

The actual query is available in http://jehiah.cz/a/oracle-date-to-unix-timestamp , but here is a slightly modified version which strips the decimal points and prints only the elapsed seconds.
---
SELECT abs(to_number(((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400)))) as dt FROM dual;
---