Re: to_timestamp() too loose? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: to_timestamp() too loose?
Date
Msg-id 10579.1345729338@sss.pgh.pa.us
Whole thread Raw
In response to to_timestamp() too loose?  (Magnus Hagander <magnus@hagander.net>)
Responses Re: to_timestamp() too loose?
List pgsql-hackers
Magnus Hagander <magnus@hagander.net> writes:
> 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?

to_timestamp is intentionally pretty loose.  Personally, if I wanted
sanity checking on a date string in any common format, I would just
cast the string to timestamp(tz), and *not* use to_timestamp.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: new --maintenance-db options
Next
From: Magnus Hagander
Date:
Subject: Re: to_timestamp() too loose?