find how many weeks difference between two dates postgresql code example
Example 1: postgresql get difference in hours between two dates
select EXTRACT(
EPOCH FROM now() - (now() - INTERVAL '5 HOUR')
)/3600
-- it will return 5
Example 2: postgresql get difference between two dates
select age('2010-04-01', '2012-03-05'),
date_part('year',age('2010-04-01', '2012-03-05')),
date_part('month',age('2010-04-01', '2012-03-05')),
date_part('day',age('2010-04-01', '2012-03-05'));