Re: to_char(interval) --- done?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: to_char(interval) --- done?
Дата
Msg-id 200303260953.58806.josh@agliodbs.com
обсуждение исходный текст
Ответ на Re: to_char(interval) --- done?  (Larry Rosenman <ler@lerctr.org>)
Ответы Re: to_char(interval) --- done?  (Larry Rosenman <ler@lerctr.org>)
Список pgsql-hackers
Larry,

> > What about EXTRACT(months FROM <interval_field>)?
> >
> > This annoyingly wraps around if it's more than 12 months, but that was
> > part of  my proposal ...
> I needed like 5 years (60 months)...
>
> So, the wrap around is not good in this case.

Easy:
CREATE FUNCTION show_months ( interval ) returns text as '
SELECT CAST( (( extract(years from $1) * 12 ) + extract(months from $1)) AS
text ) || '' months'';
' LANGUAGE SQL IMMUTABLE STRICT;

(above not checked for typos)

I'd swear that you posted your question on pgsql-sql and I posted the above
solution some months ago.

--
-Josh BerkusAglio Database SolutionsSan Francisco



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

Предыдущее
От:
Дата:
Сообщение: Win32 Postgresql version.
Следующее
От: Larry Rosenman
Дата:
Сообщение: Re: to_char(interval) --- done?