to_timestamp() too loose?

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: to_timestamp() too loose?
Date: 2012-08-23 08:37:48
Message-ID: CABUevEzwqErPtzprf34Z1oceC5a581gkX6=-M54XBtHhqgoHRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

postgres=# select to_timestamp('2012-08-01', 'yyyy-mm-dd');
to_timestamp
------------------------
2012-08-01 00:00:00+02

postgres=# select to_timestamp('2012-08-00', 'yyyy-mm-dd');
to_timestamp
------------------------
2012-08-01 00:00:00+02

postgres=# select to_timestamp('2012-00-00', 'yyyy-mm-dd');
to_timestamp
------------------------
2012-01-01 00:00:00+01

Should we really convert 00 to 01?

We also do things like:
postgres=# select to_timestamp('2012-00-99', 'yyyy-mm-dd');
to_timestamp
------------------------
2012-04-08 00:00:00+02

And while I guess there's some logic in that, it's not documented
AFAICT. Or am I just not finding the docs?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2012-08-23 10:17:22 Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https
Previous Message Peter Eisentraut 2012-08-23 07:22:08 Re: new --maintenance-db options