Re: Formatting an Interval

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Formatting an Interval
Дата
Msg-id 20041231194118.GA23987@winnie.fuhr.org
обсуждение исходный текст
Ответ на Formatting an Interval  (Jamison Roberts <jamisonroberts@gmail.com>)
Ответы Re: Formatting an Interval
Re: Formatting an Interval
Список pgsql-sql
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.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Предыдущее
От: Jamison Roberts
Дата:
Сообщение: Formatting an Interval
Следующее
От: TJ O'Donnell
Дата:
Сообщение: Re: Function in C++