Re: Re: to_date problems (Re: Favor for Postgres User at WSI)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: Kate Collins <klcollins(at)wsicorp(dot)com>, pgsql-bugs(at)postgresql(dot)org, John Rickman <john(dot)rickman(at)greatbridge(dot)com>
Subject: Re: Re: to_date problems (Re: Favor for Postgres User at WSI)
Date: 2000-11-08 15:27:17
Message-ID: 26616.973697237@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> writes:
>> I dunno whether there is any actual spec for to_date(), but I do agree
>> that if you've specified a 2-digit YY format, something 2000-centric
>> would be more useful than the current behavior.
>>
>> It doesn't seem to be doing anything particularly sensible with a
>> 4-digit date, either:
>>
>> regression=# select to_date( '00001112', 'YYYYMMDD');
>> to_date
>> ------------
>> 1112-11-12
>> (1 row)
>>
>> This case I *would* have expected to produce 1 BC, but nope...

> Where is *guarantee* that the year is 4-digits?!

Who said anything about a guarantee? In the cases at hand, the number
of Y's appearing in the format string should give you a sufficient clue
about how to behave. In fact, if I were you I'd reject a format string
that had a number of Y's other than 2 or 4, because then it really isn't
very clear what you're supposed to do.

> And 'YY' - it's hell, what is '00'? ... 1900 or 2000 or 20000?

It should work the same as the timestamp input converter. Thomas
Lockhart could give you more details about exactly what that code does.
It's probably assuming that the intended value of a 2-digit year is
between 1970 and 2069, or some other 100-year range that contains
current time.

Assuming that YY = '00' means 1 BC is definitely not reasonable
behavior, at least not in the USA. 2-digit year notations are
very common here, and no one uses them that way ;-)

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Limin Liu 2000-11-09 02:15:30 unreachable block
Previous Message Kate Collins 2000-11-08 15:16:59 Re: to_date problems (Re: Favor for Postgres User at WSI)