Skip site navigation (1) Skip section navigation (2)

BUG #6231: weird to_timestamp behaviour with out of range values

From: "Henk Enting" <h(dot)d(dot)enting(at)mgrid(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6231: weird to_timestamp behaviour with out of range values
Date: 2011-09-28 14:55:57
Message-ID: 201109281455.p8SEtveU095497@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      6231
Logged by:          Henk Enting
Email address:      h(dot)d(dot)enting(at)mgrid(dot)net
PostgreSQL version: 9.1.1
Operating system:   linux x86_64
Description:        weird to_timestamp behaviour with out of range values
Details: 

I would expect the to_timestamp function to return an error when I feed it
out of range values, e.g. months > 13 and days > 31. Instead it seems to add
the surplus to the timestamp and then return it.

E.g. 21-21 becomes sept. 22th the next year.

psql output:

postgres=# select to_timestamp('2011-21-21', 'YYYY-MM-DD');
      to_timestamp      
------------------------
 2012-09-22 00:00:00+02
(1 row)

postgres=# select to_timestamp('2011-21-42', 'YYYY-MM-DD');
      to_timestamp      
------------------------
 2012-10-13 00:00:00+02
(1 row)

Responses

pgsql-bugs by date

Next:From: Josh KupershmidtDate: 2011-09-28 15:40:37
Subject: Re: Problems with ENUM type manipulation in 9.1
Previous:From: Alvaro HerreraDate: 2011-09-28 14:51:40
Subject: Re: Problems with ENUM type manipulation in 9.1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group