Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2C76CB5DBC4 for ; Mon, 18 Jul 2011 19:02:34 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 34087-02 for ; Mon, 18 Jul 2011 22:02:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id D647FB5D803 for ; Mon, 18 Jul 2011 19:02:27 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p6IM2Ri03591; Mon, 18 Jul 2011 18:02:27 -0400 (EDT) From: Bruce Momjian Message-Id: <201107182202.p6IM2Ri03591@momjian.us> Subject: Re: to_char() accepting invalid dates? In-Reply-To: To: Thomas Kellerer Date: Mon, 18 Jul 2011 18:02:27 -0400 (EDT) CC: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.035 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.135 X-Spam-Level: X-Archive-Number: 201107/81 X-Sequence-Number: 35651 Thomas Kellerer wrote: > Jasen Betts wrote on 18.07.2011 11:23: > >> postgres=> select to_date('20110231', 'yyyymmdd'); > >> > >> to_date > >> ------------ > >> 2011-03-03 > >> (1 row) > >> > >> is there a way to have to_date() raise an exception in such a case? > > > > it's possible the odd behaviour you get is required by some standard. > > That would be *very* odd indeed. > > > > jasen=# select '20110303'::date; > Thanks for the tip, this was more a question regarding _why_ to_char() behaves this way. Well, to_char() is based on Oracle's to_char(). How does Oracle handle such a date? -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +