Re: BUG #6243: Strange result of to_date function

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: pasman <pasman(dot)p(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6243: Strange result of to_date function
Date: 2011-10-19 12:10:55
Message-ID: CA+TgmoY5VOdGWV=fRpE9PQ2JxnLzT5=KogmsNCWNNw4RNAneMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Oct 7, 2011 at 6:41 AM, pasman <pasman(dot)p(at)gmail(dot)com> wrote:
>
> The following bug has been logged online:
>
> Bug reference:      6243
> Logged by:          pasman
> Email address:      pasman(dot)p(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2011-10-19 12:29:27 Re: reporting weirdness in configure output
Previous Message Robert Haas 2011-10-19 12:04:00 Re: Compile bug: 9.1.1 with dtrace on OpenIndiana 151a (OpenSolaris 5.11)?