From: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | Jamison Roberts <jamisonroberts(at)gmail(dot)com>, List pgsql-sql <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Re: Formatting an Interval |
Date: | 2005-01-02 16:19:23 |
Message-ID: | 1104682763.3610.2.camel@petra |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, 2004-12-31 at 12:41 -0700, Michael Fuhr wrote:
> On Fri, Dec 31, 2004 at 11:37:32AM -0500, Jamison Roberts wrote:
>
> > All of the functions that i've looked at seem to only extract parts
> > from Intervals. What I need to do is to format the interval. For
> > instance, I have a Interval with the value 1 day 07:57:52. I would
> > like that in HH:MM:SS. So in the example the output would be
> > 31:57:52.
>
> I'm not aware of a built-in way to get such a format; somebody
> please correct me if I'm mistaken.
>
> You could write a function to format the interval. For example,
> with PL/pgSQL you could use EXTRACT(epoch FROM interval_value) to
> convert the interval to a number of seconds; convert that to hours,
> minutes, and seconds; and use TO_CHAR to format the return value.
to_char() works with standard date/time ranges, for example 1-24 -- so
there is no way how convert to anything like "31:57:52".
Karel
--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-01-02 16:39:40 | Re: Formatting an Interval |
Previous Message | Miles Keaton | 2005-01-02 10:05:18 | one table being used for two purposes with foreign key for each? |