Re: to_char incompatibility

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: to_char incompatibility
Date: 2008-01-16 22:06:34
Message-ID: 200801162206.m0GM6Y025373@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
> 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?
>

If we didn't print +4 digits for YYYY we would need new patterns for >4
digit years, like 5 and 6-digit years. Our documentation is at least
clear:

<entry><literal>YYYY</literal></entry>
<entry>year (4 and more digits)</entry>

> 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

Yea, I can't find any way to suppress those leading zeros, except by
using the proper number of Y's.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2008-01-16 22:16:02 Re: Postgresql Materialized views
Previous Message Tom Lane 2008-01-16 21:48:41 Re: COPY encoding