Re: convert sum (interval) to seconds

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Doppelganger <quadratini(at)sni(dot)ph>, pgsql-sql(at)postgresql(dot)org
Subject: Re: convert sum (interval) to seconds
Date: 2002-09-03 13:37:27
Message-ID: 5238.1031060247@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
> On Tue, 2002-09-03 at 11:45, Doppelganger wrote:
>> How can I convert sum(interval) to seconds?

> Here's one way;

> junk=# select extract (minute from sum(if)) * 60 + extract (second
> from sum(if)) from i;

EXTRACT(EPOCH FROM interval) is designed for this ...

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Darren Ferguson 2002-09-03 14:56:28 Re: Why must the function that a trigger calls return
Previous Message Hubert depesz Lubaczewski 2002-09-03 13:22:07 tree structures in sql - my point of view (with request of comment from joe celko)