'Find the difference in seconds between two dates [duplicate]

I have following query in oracle to get diff in seconds

SELECT TO_DATE('a', 'dd-mm-yyyy hh24:mi:ss') - TO_DATE(Q'b', 'dd-mm-yyyy hh24:mi:ss') 
FROM dual

i'm looking for equivalent query in postgres



Solution 1:[1]

You can do it like this:

SELECT EXTRACT(EPOCH FROM (timestamp1- timestamp2)) FROM dual

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1