Answers for "PostgreSQL date difference in days"

SQL
1

postgres date difference seconds

-- difference in seconds between two dates

select extract(epoch from ('2020-03-30 09:55:56'::timestamp - '2020-03-30 08:54:55'::timestamp));
-- result : 3661
Posted by: Guest on October-14-2020
2

postgresql get difference in hours between two dates

select EXTRACT(
	EPOCH FROM now() - (now() - INTERVAL '5 HOUR')
)/3600

-- it will return 5
Posted by: Guest on March-04-2021

Code answers related to "PostgreSQL date difference in days"

Code answers related to "SQL"

Browse Popular Code Answers by Language