pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: sunitha.mudumba@blss.com.au
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8216: TO_DATE does not support th format provided
Date: Fri, 07 Jun 2013 09:41:45 -0400
Message-ID: <21659.1370612505@sss.pgh.pa.us> (raw)
In-Reply-To: <E1Ukmke-0008Rf-AX@wrigleys.postgresql.org>
References: <E1Ukmke-0008Rf-AX@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

sunitha.mudumba@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



view thread (2+ messages)

Message-ID: <21659.1370612505@sss.pgh.pa.us>
Permalink:  ../21659.1370612505@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21659.1370612505@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, sunitha.mudumba@blss.com.au
  Subject: Re: BUG #8216: TO_DATE does not support th format provided
  In-Reply-To: <21659.1370612505@sss.pgh.pa.us>
  References: <E1Ukmke-0008Rf-AX@wrigleys.postgresql.org> <21659.1370612505@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox