From: Bruno Wolff III <bruno@wolff.to>
To: Plant Thomas <Thomas.Plant@lvh.it>
Cc: pgsql-sql@postgresql.org
Subject: Re: Sum of Intervals
Date: Wed, 12 Feb 2003 09:37:53 -0600
Message-ID: <20030212153753.GA14331@wolff.to> (raw)
In-Reply-To: <418DEFFAA399D311818A00508B912F2883D74A@idefix.lvh.dnet.it>
References: <418DEFFAA399D311818A00508B912F2883D74A@idefix.lvh.dnet.it>
On Wed, Feb 12, 2003 at 15:37:07 +0100,
Plant Thomas <Thomas.Plant@lvh.it> wrote:
> Hello,
>
> I'm trying to do a sum() of some time intervals.
> I get the result as: '1 day 02:30' which is ok, but is there a function
> which converts this to hours or do I have to write my own?
> For example the '1 day 02:30' should become 26:30 hours.
You can get the seconds using extract and then do further manipulation.
To get fractional hours you can use the example below. To get hours and
minutes you can use modular arithmatic and concatenate to build the
desired string.
area=> select extract(epoch from '1 day 02:30'::interval) / 3600;
?column?
----------
26.5
(1 row)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, Thomas.Plant@lvh.it
Subject: Re: Sum of Intervals
In-Reply-To: <20030212153753.GA14331@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox