From: | "Jesper K(dot) Pedersen" <jkp(at)solnet(dot)homeip(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: formating interval question |
Date: | 2004-09-24 12:20:09 |
Message-ID: | 20040924142009.30044256.jkp@solnet.homeip.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 24 Sep 2004 11:58:44 +0100
mike(at)bristolreccc(dot)co(dot)uk (mike) wrote:
> I have an interval field which is used to calculate total hours.
> At present it outputs as days hours minutes
> Is there any way to output as total hours
> I have tried to_char(field,'HH:MM')
> but I get wierd results like -51 or -5
>
From the top of my head i think could probably to do something like
this:
extract(epoch from your_time_interval)/3600
It basically finds the "age" of your interval in seconds. The /3600 is
to find the result in hours.
If you for instance want the result with just one decimal like xxxx.y
then you can do it like this:
round(extract(epoch from your_time_interval)/360)/10
I hope this helps.
Best regards
Jesper K. Pedersen
From | Date | Subject | |
---|---|---|---|
Next Message | Willy Skjæveland | 2004-09-24 12:42:04 | Is linked servers possible with postgresql? |
Previous Message | Robert Fitzpatrick | 2004-09-24 12:07:37 | PostgreSQL 8 on Win2003 AD server |