Solved

PostGreSQL Get difference between two Timestamp in minutes

Posted on 2004-10-19
3
4,304 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 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now