Date difference in seconds

From: "Raghunath T" <raghunatht(at)mindtree(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Date difference in seconds
Date: 2001-02-19 00:11:30
Message-ID: 7D6D227F5351FA4FB0A6B6FDBC0578F2038432@hqbng01ex01.mindtree.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi ,
Please consider the following schema and the query given below and
let me know how to get the results I want.

CREATE TABLE temp (
id INTEGER NOT NULL,
start_time TIMESTAMP,
end_time TIMESTAMP,
PRIMARY KEY (id)
);

Now I want the difference between start time and end time in seconds.
Select date_part('seconds',start_time - end_time) from temp; gives
me only the difference between the seconds value in both timestamps. It
ignores all the days, hrs, minutes etc.

My problem is that I want the actual difference between the two timestamps
expressed in seconds.

Please advice me how to write the SQL Query.

With Regards,
Raghunath T
Senior Software Engg,
MindTree Consulting Private Ltd,
Santa Clara, CA, USA

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark Cowlishaw 2001-02-19 01:03:35 Re: troublesome inputs
Previous Message Tom Lane 2001-02-19 00:07:39 Re: How to use gethostbyname()