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
|
Список | 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 по дате отправления: