Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PostGreSQL Get difference between two Timestamp in minutes

Posted on 2004-10-19
3
Medium Priority
?
6,476 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:ekartha
  • 2
3 Comments
 
LVL 32

Expert Comment

by:ldbkutty
ID: 12345852
0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 2000 total points
ID: 12345948
Ok..here is an exact solution:

SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-09-29 13:00' - TIMESTAMP '2001-09-29 12:00')/60;
0
 
LVL 22

Expert Comment

by:earth man2
ID: 12352614
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)
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question