Re: BUG #4539: to_char(to_timestamp('...','....')) returns the wrong result

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Stuart Green <stuart(at)greenfam(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4539: to_char(to_timestamp('...','....')) returns the wrong result
Date: 2008-11-20 08:53:43
Message-ID: 49252597.3000109@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Stuart Green wrote:
> select to_char(to_timestamp('2008-11-14 16:00:00','YYYY-MM-DD
> HH24:MM:SS'),'day');
>
> is returning monday as the day in all the dbase version I Have test, 8.2.11,
> 8.2.10, and 8.1.11

Use 'MI' instead of 'MM' for the minutes. to_timestamp is quite lenient,
and interpretes the 00 in what you meant to be the minutes field as
month number. As there is no month 0, it uses January.

to_timestamp is much stricter in the upcoming 8.4 release, and will
throw an error for that query:

postgres=# select to_char(to_timestamp('2008-11-14 16:00:00','YYYY-MM-DD
HH24:MM:SS'),'day');
ERROR: conflicting values for "MM" field in formatting string
DETAIL: This value contradicts a previous setting for the same field type.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomasz Ostrowski 2008-11-20 09:30:57 Re: substring with this pattern works in 8.3.1; does not work in 8.3.4
Previous Message Stuart Green 2008-11-19 22:03:31 BUG #4539: to_char(to_timestamp('...', '....')) returns the wrong result