ekartha
asked on
PostGreSQL Get difference between two Timestamp in minutes
Hi sir,
I would be thankful to you if you could provide me the SQL query (PostgreSQL specific) to get differnce between two Timestamp in minutes. Its urgent.
I would be thankful to you if you could provide me the SQL query (PostgreSQL specific) to get differnce between two Timestamp in minutes. Its urgent.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
he's right you may want to cast it as int if you want to round down minutes.
demo=> select extract ( epoch from (interval '349 second'))/60;
?column?
------------------
5.81666666666667
(1 row)
demo=> select extract ( epoch from (interval '349 second'))::int/60;
?column?
----------
5
(1 row)
demo=> select extract ( epoch from (interval '349 second'))/60;
?column?
------------------
5.81666666666667
(1 row)
demo=> select extract ( epoch from (interval '349 second'))::int/60;
?column?
----------
5
(1 row)
http://www.postgresql.org/docs/7.4/static/functions-datetime.html#FUNCTIONS-DATETIME-TABLE