From: | elwood(at)agouros(dot)de (Konstantinos Agouros) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: One more question about intervals |
Date: | 2001-11-04 20:28:08 |
Message-ID: | elwood.1004905636@news.agouros.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
In <Pine(dot)LNX(dot)4(dot)30(dot)0111041143020(dot)19169-100000(at)commandprompt(dot)com> pgsql-general(at)commandprompt(dot)com ("Command Prompt, Inc.") writes:
>On Sun, 4 Nov 2001, Konstantinos Agouros wrote:
>in the largest units possible first, with each unit's field being a
>discrete value; it looks like the EPOCH field is the only one guaranteed
>to give you a combined length of time for the entire duration of the
>interval, so you're definitely on the right track with that.
>You could create a function like this to make your life a little easier:
>CREATE FUNCTION get_hours (interval)
> RETURNS int4
> AS 'SELECT round(extract(EPOCH FROM $1) / 3600.0)::integer'
> LANGUAGE 'sql';
>Depending on whether or not you wanted to round up, down, or to the
>nearest hour, you'd use ceil(), floor(), or round() respectively, on the
>result of the division.
extract epoch from was what I needed to get this where I can work with it.
A time-formatter will come later \:)
Thanks,
Konstantin
>Then you'd just have to do:
>lx=# SELECT get_hours(sum(i)) * 100 || ' Euros' AS cost
>lx-# FROM my_intervals;
> cost
>------------
> 7500 Euros
>(1 row)
>Regards,
>Jw.
>--
>jlx(at)commandprompt(dot)com
>by way of pgsql-general(at)commandprompt(dot)com
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood(at)agouros(dot)de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not survive the forming of the cosmos." B'Elana Torres
From | Date | Subject | |
---|---|---|---|
Next Message | Kenneth Skiles | 2001-11-04 20:33:37 | functions, shell script |
Previous Message | Command Prompt, Inc. | 2001-11-04 19:55:57 | Re: One more question about intervals |