Re: Proposed changing the definition of decade for date_trunc and extract

Поиск
Список
Период
Сортировка
От Mike Swanson
Тема Re: Proposed changing the definition of decade for date_trunc and extract
Дата
Msg-id 1407048786.31613.2.camel@gmail.com
обсуждение исходный текст
Ответ на Re: Re: Proposed changing the definition of decade for date_trunc and extract  (Mike Swanson <mikeonthecomputer@gmail.com>)
Ответы Re: Proposed changing the definition of decade for date_trunc and extract  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-hackers
On Fri, 2014-08-01 at 22:28 -0700, Mike Swanson wrote:
> I'd also argue that the current function basing the logic from
> definition #2 has limited use even when you want to use it for such.
> If you want to generate text for '(decades)s' you'd have to do:
>   SELECT extract('year' from date_trunc('decade', now())) || 's';
> Or with my patch:
>   SELECT floor(extract('year' from now()) / 10) || '0s';
> It's different, for sure, but I would actually think the second one is
> a bit less awkward.  Plus it's shorter :)

I'm responding to myself because I realized that what I wrote was a bit
silly.  The first and current example (which is invalidated by my patch)
should really be: SELECT extract('decade' from now()) || '0s';
which makes it the shorter and simpler version of the two.  I'll still
stand by my opinion that it's not an extremely useful function as it is.




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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: a fast bloat measurement tool (was Re: Measuring relation free space)
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: B-Tree support function number 3 (strxfrm() optimization)