sunitha.mudu...@blss.com.au writes:
> To_date does not throw an error when an invalid date is provided to it
> select to_date('10-30-2012','dd-MM-YYYY');

That's not a bug; it's operating as designed.  If you want more error
checking, don't use to_date() --- just cast the string to date.

regression=# show datestyle;
 DateStyle 
-----------
 ISO, MDY
(1 row)

regression=# select '10-30-2012'::date;
    date    
------------
 2012-10-30
(1 row)

regression=# set datestyle = dmy;
SET
regression=# select '10-30-2012'::date;
ERROR:  date/time field value out of range: "10-30-2012"
LINE 1: select '10-30-2012'::date;
               ^
HINT:  Perhaps you need a different "datestyle" setting.

                        regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to