Skip site navigation (1) Skip section navigation (2)

Re: to_date gives odd results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: to_date gives odd results
Date: 2007-08-31 01:15:47
Message-ID: 11842.1188522947@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> writes:
> pagila=# select to_date('05 December 2000', 'DD Month YYYY');
> to_date
> ---------------
> 0001-12-05 BC
> (1 row)

> I can't imagine that's expected behavior.... bug? 

You needed to say FMMonth, else it expects fixed-width column.

to_date and friends are fairly awful in terms of not throwing errors
when the input doesn't really match the format.  I think what you
shoulda got here is a bad-input error.  However, somebody's going to
have to do a major rewrite of formatting.c to make it much better...

(Hmmm ... actually, in CVS HEAD this produces 2000-12-05 with or without
FM, which looks like a rather ill-considered change to try to make
things work "nicely".  The problem that it goes south on actually bad
input is still there.)

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Robert TreatDate: 2007-08-31 01:35:37
Subject: Re: to_date gives odd results
Previous:From: Marshall, SteveDate: 2007-08-30 21:44:20
Subject: Re: BUG #3504: Some listening sessions never return from writing, problems ensue

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group