Re: to_char incompatibility

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: to_char incompatibility
Date: 2008-01-16 10:28:12
Message-ID: 200801161128.13257.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Am Donnerstag, 10. Januar 2008 schrieb Roberts, Jon:
> > On PostgreSQL:
> >
> > select to_date('31-DEC-200700:00:00', 'dd-mon-yyyy hh24:mi:ss');
> > to_date
> > --------------
> > 200700-12-31

> Oracle removes all white spaces in the date you pass in and the date
> format.

I don't have a strong opinion on the whitespace handling, but then I wonder

1. If I put four YYYY, why does it create a six-digit year?

2. If it does create a six digit year, the rest of the pattern doesn't match
anymore, so it should error.

A further example shows that to_date seems to have little error checking
altogether:

select to_date('17.12.1978', 'YYYY-MM-DD');
to_date
------------
0017-12-19

That can't possibly be a good idea, in the interest of the robustness of
applications built on this.

select to_date('whatever', 'foobar');
to_date
---------------
0001-01-01 BC

Yah.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2008-01-16 11:16:55 Re: Postgresql Materialized views
Previous Message Jens-Wolfhard Schicke 2008-01-16 10:23:10 Re: Array behavior oddities