Re: Re: to_date problems (Re: Favor for Postgres User at WSI)
От | Tom Lane |
---|---|
Тема | Re: Re: to_date problems (Re: Favor for Postgres User at WSI) |
Дата | |
Msg-id | 26616.973697237@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: to_date problems (Re: Favor for Postgres User at WSI) (Karel Zak <zakkr@zf.jcu.cz>) |
Ответы |
Re: Re: to_date problems (Re: Favor for Postgres User at WSI)
|
Список | pgsql-bugs |
Karel Zak <zakkr@zf.jcu.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
В списке pgsql-bugs по дате отправления: