On Fri, Oct 7, 2011 at 6:41 AM, pasman <pasma...@gmail.com> wrote: > > The following bug has been logged online: > > Bug reference: 6243 > Logged by: pasman > Email address: pasma...@gmail.com > PostgreSQL version: 9.1.1 > Operating system: WinXP sp3 > Description: Strange result of to_date function > Details: > > Hi. > This is the result of to_date function: > > SELECT "data min", to_date("data min",'YYYYMMDD') > > "20110211144226";"32522-12-09" > "20110708202145";"24468-03-15" > "20101118110930";"51596-11-15" > "20101216120525";"46147-05-31" > "20110526093630";"73453-04-05"
We've had some problems like this before, and I think the date-parsing code could probably be further improvement to do less silly things when it sees unexpected input. That having been said, if you pass a 14-digit value to a date format that expects 8 digits, there's not really any reasonable way for the computer to decide what you meant. I gather that you'd like 20101216120525 to mean 2010-12-16 (and just ignore 120525) but it could also be interpreted to mean 2010121612-05-25, which is admittedly an awfully long time from now but it doesn't seem any less logical than randomly throwing away part of the input string. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs