Re: [GENERAL] to_timestamp() and quarters

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "A(dot) Kretschmer *EXTERN*" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] to_timestamp() and quarters
Date: 2010-03-03 14:25:29
Message-ID: 201003031425.o23EPTw25883@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Albe Laurenz wrote:
> > But stop, now i see:
> >
> > test=*# select to_date('2010-02-29', 'YYYY-MM-DD');
> > to_date
> > ------------
> > 2010-03-01
> > (1 row)
> >
> > So it is maybe a congruously behavior ;-)
>
> Ugh. I thought that to_date was an Oracle compatibility function.
>
> SQL> select to_date('2010-02-29', 'YYYY-MM-DD') from dual;
> select to_date('2010-02-29', 'YYYY-MM-DD') from dual
> *
> ERROR at line 1:
> ORA-01839: date not valid for month specified
>
> And for that matter:
>
> SQL> select to_date('2010-7', 'YYYY-Q') from dual;
> select to_date('2010-7', 'YYYY-Q') from dual
> *
> ERROR at line 1:
> ORA-01820: format code cannot appear in date input format
>
> Oracle allows Q only when converting date to string.
> So this can be seen as an extension.
>
> But allowing 2010-02-29 is incompatible and smacks of MySQL...

Yea, we had a similar issue with to_timestamp():

test=> SELECT to_timestamp('20096040','YYYYMMDD');
to_timestamp
------------------------
2014-01-17 00:00:00-05
(1 row)

If we are going to tighten these up, we should do them all. Right now
we allow it and for consistency should allow the Q=7 value too.

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

PG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2010-03-03 14:29:21 Re: How to grant a user read-only access to a database?
Previous Message Devrim GÜNDÜZ 2010-03-03 13:53:43 Re: FSM and VM file

Browse pgsql-hackers by date

  From Date Subject
Next Message Theo Schlossnagle 2010-03-03 14:52:46 Re: double and numeric conversion
Previous Message Fujii Masao 2010-03-03 14:03:29 Re: Streaming replication and pg_xlogfile_name()