to_date() month translation

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: to_date() month translation
Date: 2001-06-15 20:51:26
Message-ID: 200106152051.f5FKpQ113093@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrei Popov (andyelf(at)yahoo(dot)com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
to_date() month translation

Long Description
When using to_date() format conversion with an arbitrary date-string, conversion mask description does not work as expected, or as it works in most other databases where a similar function present.

It is expected that when a date-string '12-January-2001' is fed to to_date() with mask 'DD-Month-YYYY' conversion should result in 2001-01-12::date. See code sample 1 for actual result.

Replacing 'Month' with 'Mmmmmmm' provides the correct result (see sample 2), but fails with '12-June-2001' (sample 3). Blank-padding month name to 6 characters works (sample 4) always but is (as severity suggests) a major annoyance.

Sample Code
Sample 1:
---------

template1=# select to_date('12-January-2001','DD-Month-YYYY');
to_date
------------
0001-01-12
(1 row)

Sample 2:
---------

template1=# select to_date('12-January-2001','DD-Mmmmmmm-YYYY');
to_date
------------
2001-01-12
(1 row)

Sample 3:
---------

template1=# select to_date('12-June-2001','DD-Mmmmmmm-YYYY');
to_date
------------
0002-08-14
(1 row)

Sample 4:
---------

template1=# select to_date('12-January -2001','DD-Month-YYYY');
to_date
------------
2001-01-12
(1 row)

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Hiroshi Inoue 2001-06-16 01:06:10 RE: [ODBC] Re: ODBC Interface version 07_01_0005, problemwith C++ exceptions
Previous Message Tom Lane 2001-06-15 14:10:45 Re: the index on INTEGER field does not work (PG 7.1.2)