Re: One more question about intervals

From: Konstantinos Agouros <elwood(at)agouros(dot)de>
To: "Command Prompt, Inc(dot)" <pgsql-general(at)commandprompt(dot)com>
Cc: Konstantinos Agouros <elwood(at)agouros(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: One more question about intervals
Date: 2001-11-04 19:40:42
Message-ID: 20011104204042.A27702@rumba.agouros.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Nov 04, 2001 at 11:24:10AM -0800, Command Prompt, Inc. wrote:
> On Sun, 4 Nov 2001, Command Prompt, Inc. wrote:
> >Couldn't you just multiply your cumulative hours by the cost? E.g.:
> >
> >lx=# SELECT extract(DAYS FROM sum(i)) * 24 +
> >lx-# extract(HOURS FROM sum(i)) * 100 || ' Euros' AS cost
> >lx-# FROM my_intervals;
> > cost
> >-----------
> > 372 Euros
> >(1 row)
>
> Whoops! I just noticed I messed up my operator precedence there in my
> example. ;)
Actually what I would need is date_part(EPOCH) since then I am sure that it is
the seconds and I have to multiply with EURO/3600. The extract-stuff would
ignore minutes or I would have to add these also. The problem is I have to
reconstruct the hours in the format by hand and it would be nice to have the
database do this by itself \:)

Konstantin
>
> It should've read like this:
>
> lx=# SELECT (extract(DAYS FROM sum(i)) * 24 +
> lx(# extract(HOURS FROM sum(i))) * 100 || ' Euros' AS cost
> lx-# FROM my_intervals;
> cost
> ------------
> 7500 Euros
> (1 row)
>
> The point's the same, just make sure you group the time units in
> parentheses before multiplying against a currency rate (unless you want to
> severely undercharge). ;)
>
>
> Regards,
> Jw.
> --
> jlx(at)commandprompt(dot)com
> by way of pgsql-general(at)commandprompt(dot)com
>

--
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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jakub Ouhrabka 2001-11-04 19:52:05 foreign keys and deadlock
Previous Message Command Prompt, Inc. 2001-11-04 19:24:10 Re: One more question about intervals