From: | Mike Swanson <mikeonthecomputer(at)gmail(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposed changing the definition of decade for date_trunc and extract |
Date: | 2014-08-03 06:53:06 |
Message-ID: | 1407048786.31613.2.camel@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2014-08-03 06:53:11 | Re: B-Tree support function number 3 (strxfrm() optimization) |
Previous Message | Amit Kapila | 2014-08-03 05:48:57 | Re: a fast bloat measurement tool (was Re: Measuring relation free space) |