From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Mike Swanson <mikeonthecomputer(at)gmail(dot)com> |
Cc: | "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 13:27:56 |
Message-ID: | 20140803132755.GA12284@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Aug 2, 2014 at 11:53:06PM -0700, Mike Swanson wrote:
> 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.
Well, you can make the argument that since the 20th century is from 1901
to 2000, that decades should be from *01 to *00. However, those
centuries are ordinal, e.g. using "th", while decades are not. The
decade is more a short-hand, rather than something that counts from year
1 like centuries. Looking at decades as an abbreviation supports our
current behavior.
I don't think 99% of people know there was no year 0, so I don't think
you can base a lot on that.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
From | Date | Subject | |
---|---|---|---|
Next Message | Emre Hasegeli | 2014-08-03 13:48:09 | Re: KNN-GiST with recheck |
Previous Message | Peter Geoghegan | 2014-08-03 06:53:11 | Re: B-Tree support function number 3 (strxfrm() optimization) |