Re: Formatting an Interval

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Formatting an Interval
Дата
Msg-id 20050102163940.GA37196@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Formatting an Interval  (Karel Zak <zakkr@zf.jcu.cz>)
Ответы Re: Formatting an Interval  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
Список 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/


В списке pgsql-sql по дате отправления:

Предыдущее
От: Karel Zak
Дата:
Сообщение: Re: Formatting an Interval
Следующее
От: Kretschmer Andreas
Дата:
Сообщение: Re: Formatting an Interval