Re: BUG #1630: Wrong conversion in to_date() function. See example.

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ariel E(dot) Carná/Elizabeth Sosa <acarna(at)tarifar(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1630: Wrong conversion in to_date() function. See example.
Date: 2005-04-27 14:22:07
Message-ID: 20050427142207.GA47188@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Apr 26, 2005 at 11:48:12PM +0100, Ariel E. Carná/Elizabeth Sosa wrote:
>
> Case PgSQL 7.3.8/SuSE Linux 8.2 (i586)
> ======================================
> PROD=# select to_date('2005-02-32', 'YYYY-MM-DD');
> to_date
> ------------
> 2005-03-04
> (1 row)
>
> Case PgSQL 7.4.6/SuSE Linux 9.2
> (i586)======================================
> PROD=> select to_date('2005-02-32', 'YYYY-MM-DD');
> to_date
> ------------
> 04-03-2005
> (1 row)

What bug are you reporting? These are the same date displayed in
different formats -- are you familiar with the DateStyle setting?

http://www.postgresql.org/docs/7.3/interactive/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT
http://www.postgresql.org/docs/7.4/interactive/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT

test=> SELECT version();
version
---------------------------------------------------------------------------
PostgreSQL 7.4.7 on sparc-sun-solaris2.9, compiled by GCC gcc (GCC) 3.4.2
(1 row)

test=> SET DateStyle TO 'ISO,MDY';
SET
test=> SELECT to_date('2005-02-32', 'YYYY-MM-DD');
to_date
------------
2005-03-04
(1 row)

test=> SET DateStyle TO 'Postgres,DMY';
SET
test=> SELECT to_date('2005-02-32', 'YYYY-MM-DD');
to_date
------------
04-03-2005
(1 row)

If anything I'd expect 2005-02-32 to be rejected as invalid, but I
don't know the history or rationale behind to_date's behavior.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Don Courtney 2005-04-27 14:41:33 BUG #1634: Configure step for build does not define HAVE_POSIX_SIGNALS
Previous Message Achilleus Mantzios 2005-04-27 13:53:17 Re: BUG #1632: Several jailed PostgreSQL instances.