How to find number of seconds between 2 timestamps

From: "Woody Woodring" <george(dot)woodring(at)iglass(dot)net>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: How to find number of seconds between 2 timestamps
Date: 2009-02-17 15:08:56
Message-ID: 2F6F337A2AE24BD4A8D6E50FCCF5CCCD@istructure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I am trying to calculate a rate per second and am having trouble getting the
number of seconds between the two timestamps to use in the formula.

overview=> select extract(epoch from interval '1 day'::interval);
date_part
-----------
86400
(1 row)

overview=> select extract(epoch from interval ('2009-02-16
22:15:28.034567-06'::timestamp with time zone - '2009-02-15
22:15:28.034567-06'::timestamp with time zone));
ERROR: syntax error at or near "'2009-02-16 22:15:28.034567-06'"
LINE 1: select extract(epoch from interval ('2009-02-16 22:15:28.034...

Any suggestions would be helpful,

Thanks,
Woody

----------------------------------------
iGLASS Networks
3300 Green Level Rd. West
Cary NC 27519
(919) 387-3550 x813
www.iglass.net

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2009-02-17 15:30:44 Re: How to find number of seconds between 2 timestamps
Previous Message A. Kretschmer 2009-02-17 14:45:50 Re: Is this possible?