Re: to_char(interval) --- done?

Поиск
Список
Период
Сортировка
Искать
От
Larry Rosenman
Тема
Re: to_char(interval) --- done?
Дата
Msg-id
150050000.1048701690@lerlaptop.iadfw.net
Ответ на
Список
Дерево обсуждения
to_char(interval) --- done? Josh Berkus <josh@agliodbs.com>
Re: to_char(interval) --- done? Karel Zak <zakkr@zf.jcu.cz>
Re: to_char(interval) --- done? Larry Rosenman <ler@lerctr.org>
Re: to_char(interval) --- done? Josh Berkus <josh@agliodbs.com>
Re: to_char(interval) --- done? Karel Zak <zakkr@zf.jcu.cz>
Re: to_char(interval) --- done? Alvaro Herrera <alvherre@dcc.uchile.cl>
Re: to_char(interval) --- done? Karel Zak <zakkr@zf.jcu.cz>


--On Wednesday, March 26, 2003 09:53:58 -0800 Josh Berkus 
 wrote:

> Larry,
>
>> > What about EXTRACT(months FROM )?
>> >
>> > 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.
I did post, but this solution did **NOT** get posted.  So, I kept my field 
as
INT.

BUT, thank you for this.

LER

>
> --
> -Josh Berkus
>  Aglio Database Solutions
>  San Francisco
>



-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


В списке pgsql-hackers по дате отправления
От: Josh Berkus
Дата:
От: Greg Stark
Дата:
FAQ