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/