Re: Using YY-MM-DD date input

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(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:13:41
Message-ID: 28069.1059164021@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

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.)

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.

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'.

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.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Elielson Fontanezi 2003-07-25 20:20:15 RES: ERROR: DefineIndex: index function must be marked iscachable
Previous Message Bruce Momjian 2003-07-25 20:02:07 Using YY-MM-DD date input