Re: Using YY-MM-DD date input - Mailing list pgsql-general

From Tom Lane
Subject Re: Using YY-MM-DD date input
Date
Msg-id 28069.1059164021@sss.pgh.pa.us
Whole thread Raw
In response to Using YY-MM-DD date input  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Using YY-MM-DD date input  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
Bruce Momjian <pgman@candle.pha.pa.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

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Using YY-MM-DD date input
Next
From: Elielson Fontanezi
Date:
Subject: RES: ERROR: DefineIndex: index function must be marked iscachable