Re: [GENERAL] to_timestamp() and quarters

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "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 08:11:00
Message-ID: D960CB61B694CF459DCFB4B0128514C2039381CB@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

A. Kretschmer *EXTERN*
> > Well, I can easily make it do what you expect, and I don't see many
> > error returns in that area of the code, so I just wrote a patch that
> > does what you would expect rather than throw an error.
>
> Well, that's great and better than an error, thx.
>
> > test=> select to_date('2010-7', 'YYYY-Q');
> > to_date
> > ------------
> > 2011-07-04
> > (1 row)
>
> Is this per SQL-Spec? I would expect an error for a quarter not in
> (1,2,3,4).
>
> 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...

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben Eliott 2010-03-03 09:07:40 Fwd: createdb but revoke dropdb
Previous Message A. Kretschmer 2010-03-03 05:55:43 Re: [GENERAL] to_timestamp() and quarters

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-03-03 08:36:47 Re: USE_LIBXSLT in MSVC builds
Previous Message Jaime Casanova 2010-03-03 06:37:30 Re: Re: [COMMITTERS] pgsql: Instead of trying (and failing) to allow <<label>> at the end of