dbTalk Databases Forums  

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

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. - 04-27-2005 , 09:23 AM






On Tue, Apr 26, 2005 at 11:48:12PM +0100, Ariel E. Carná/Elizabeth Sosa wrote:
Quote:
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/i...ATETIME-OUTPUT
http://www.postgresql.org/docs/7.4/i...ATETIME-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/

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. - 04-27-2005 , 09:47 AM






"Ariel E. Carná/Elizabeth Sosa" <acarna (AT) tarifar (DOT) com> writes:
Quote:
PROD=# select to_date('2005-02-32', 'YYYY-MM-DD');
to_date
------------
2005-03-04
(1 row)
I'm not convinced that's a bug --- most implementations of the Unix
mktime function will handle out-of-range day numbers like that.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
  #3  
Old   
Juan Miguel Paredes
 
Posts: n/a

Default Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. - 04-27-2005 , 09:52 AM



------=_Part_1763_32557864.1114613423403
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Even javascript handles those dates the same way...

On 4/27/05, Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> wrote:=20
Quote:
=20
"Ariel E. Carn=C3=A1/Elizabeth Sosa" <acarna (AT) tarifar (DOT) com> writes:
PROD=3D# select to_date('2005-02-32', 'YYYY-MM-DD');
to_date
------------
2005-03-04
(1 row)
=20
I'm not convinced that's a bug --- most implementations of the Unix
mktime function will handle out-of-range day numbers like that.
=20
regards, tom lane
=20
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
=20
http://www.postgresql.org/docs/faq

------=_Part_1763_32557864.1114613423403
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<div>Even javascript handles those dates the same way...</div>
<div><br>&nbsp;</div>
<div><span class=3D"gmail_quote">On 4/27/05, <b class=3D"gmail_sendername">=
Tom Lane</b> &lt;<a href=3D"mailto:tgl (AT) sss (DOT) pgh.pa.us">tgl (AT) sss (DOT) pgh.pa.us</a>=
Quote:
wrote:</span
blockquote class=3D"gmail_quote" style=3D"PADDING-LEFT: 1ex; MARGIN: 0px 0=
px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">&quot;Ariel E. Carn=C3=A1/Elizab=
eth Sosa&quot; &lt;<a href=3D"mailto:acarna (AT) tarifar (DOT) com">acarna (AT) tarifar (DOT) com=
</a>&gt; writes:
<br>&gt; PROD=3D# select to_date('2005-02-32', 'YYYY-MM-DD');<br>&gt;&nbsp;=
&nbsp; to_date<br>&gt; ------------<br>&gt;&nbsp;&nbsp;2005-03-04<br>&gt; (=
1 row)<br><br>I'm not convinced that's a bug --- most implementations of th=
e Unix<br>mktime function will handle out-of-range day numbers like that.
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp; regards, =
tom lane<br><br>---------------------------(end of broadcast)--------------=
-------------<br>TIP 5: Have you checked our extensive FAQ?<br><br>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp=
;<a href=3D"http://www.postgresql.org/docs/faq">
http://www.postgresql.org/docs/faq</a><br></blockquote></div><br>
------=_Part_1763_32557864.1114613423403--


Reply With Quote
  #4  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. - 04-27-2005 , 09:54 AM



Michael Fuhr <mike (AT) fuhr (DOT) org> writes:
Quote:
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.
It is rejected by the standard date input converter:

regression=# select '2005-02-32'::date;
ERROR: date/time field value out of range: "2005-02-32"
HINT: Perhaps you need a different "datestyle" setting.

However we consider that to_date() exists to be Oracle compatible,
and so I would regard this as a bug if and only if Oracle does
something different with the same input. Anyone know?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #5  
Old   
Shelby Cain
 
Posts: n/a

Default Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. - 04-27-2005 , 10:15 AM



Quote:
However we consider that to_date() exists to be
Oracle compatible,
and so I would regard this as a bug if and only if
Oracle does
something different with the same input. Anyone
know?

Here is the output I get from Oracle:
================================================== ===

Connected to:
Oracle8 Enterprise Edition Release 8.0.6.3.0 -
Production

SELECT to_date('2005-02-27', 'YYYY-MM-DD') from dual
TO_DATE('2005-02-27','YYYY-MM-
------------------------------
2/27/2005
1 row selected

SELECT to_date('2005-02-29', 'YYYY-MM-DD') from dual
ORA-01839: date not valid for month specified

SELECT to_date('2005-02-32', 'YYYY-MM-DD') from dual;
ORA-01847: day of month must be between 1 and last day
of month

===========================================

Regards,

Shelby Cain

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #6  
Old   
Ariel Carna
 
Posts: n/a

Default Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See example. - 04-27-2005 , 10:27 AM



With Oracle (at least since 6.x version) this conversion is wrong.


Atentamente ,=20

Ariel Carn=E1




-----Mensaje original-----
De: Tom Lane [mailto:tgl (AT) sss (DOT) pgh.pa.us]=20
Enviado el: Mi=E9rcoles, 27 de Abril de 2005 11:54 a.m.
Para: Michael Fuhr
CC: Ariel E. Carn=C3=A1/Elizabeth Sosa; pgsql-bugs (AT) postgresql (DOT) org
Asunto: Re: [BUGS] BUG #1630: Wrong conversion in to_date() function. See
example.=20

Michael Fuhr <mike (AT) fuhr (DOT) org> writes:
Quote:
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.
It is rejected by the standard date input converter:

regression=3D# select '2005-02-32'::date;
ERROR: date/time field value out of range: "2005-02-32"
HINT: Perhaps you need a different "datestyle" setting.

However we consider that to_date() exists to be Oracle compatible,
and so I would regard this as a bug if and only if Oracle does
something different with the same input. Anyone know?

regards, tom lane


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.