Re: Using YY-MM-DD date input

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: Using YY-MM-DD date input
Date: 2003-07-25 20:34:21
Message-ID: 200307252034.h6PKYLX20343@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Does anyone use YY-MM-DD for date input?
> > We are considering eliminating it for 7.4. You can still use
> > yyyy-mm-dd, or course.
>
> The way I think the date input parser should work when seeing three
> numeric values is:
>
> 1. If first field has four digits, then format is yyyy-mm-dd.

OK

> 2. If first field is larger than 31, assume format is yy-mm-dd.
> (I'm not totally wedded to this, since it could be argued to be
> allowing the input values to determine the interpretation, which
> is exactly the kind of heuristic that people objected to in the
> dd/mm vs mm/dd discussion last month. It seems reasonable to me,
> but it could be removed without affecting the rest of this proposal.)

I am not excited about this, though you could say it is an extension of
the 4-digit rule. However, I don't like that 30-03-03 is in 2003 and
32-03-03 is in the year 32AD. That seems error-prone to me. :-)

> 3. Otherwise, the format must be one of yy-mm-dd, dd-mm-yy, or mm-dd-yy.
> We should use DateStyle to decide which one of these applies.

I see this as a feature addition, because right now, in 2003, there is
no way to enter a current date with a leading year using only two digits.

Also, if there aren't many people who want it, I am concerned it will
cause confusion, because our datestyle stuff is already complicated.

> There are presently only two input DateStyles ('US' and 'European') but
> it would be trivial to add a third to accept yy-mm-dd. We'd only need
> to figure out what to call it. I'm tempted to just call it 'YMD' and
> provide 'DMY' and 'MDY' as alternative names for 'US' and 'European'.

Now, that is an interesting idea, and I wonder if they aren't better
than US and European (and German), because they are more general.

Is this something we want to do in feature freeze?

> We could also use datestyle to decide what to do with ambiguous inputs
> like 03-FEB-01 --- given a 3-way input DateStyle, I'd say YMD should
> mean that the year is first, while the other two mean the day is first.

Interesting.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-07-25 20:36:30 Re: Using YY-MM-DD date input
Previous Message Jonathan Bartlett 2003-07-25 20:26:57 Function index qeustion