From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> |
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:39:40 |
Message-ID: | 20050102163940.GA37196@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Sun, Jan 02, 2005 at 05:19:23PM +0100, Karel Zak wrote:
> On Fri, 2004-12-31 at 12:41 -0700, Michael Fuhr wrote:
>
> > 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".
TO_CHAR() works with several types, including integer, numeric, and
double precision. If you've broken the interval into three variables,
one containing hours, one containing minutes, and one containing
seconds, then you can use TO_CHAR() to add leading zeroes where
needed.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Kretschmer Andreas | 2005-01-02 16:46:52 | Re: Formatting an Interval |
Previous Message | Karel Zak | 2005-01-02 16:19:23 | Re: Formatting an Interval |