Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VFe1a-0008EI-6A for pgsql-admin@arkaria.postgresql.org; Sat, 31 Aug 2013 05:47:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VFe1Z-00087a-DM for pgsql-admin@arkaria.postgresql.org; Sat, 31 Aug 2013 05:47:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VFe1Y-00087T-C4 for pgsql-admin@postgresql.org; Sat, 31 Aug 2013 05:47:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VFe1V-00058P-Qc for pgsql-admin@postgresql.org; Sat, 31 Aug 2013 05:47:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r7V5l0Vm014884; Sat, 31 Aug 2013 01:47:00 -0400 From: Tom Lane To: Technical Doubts cc: pgsql-admin@postgresql.org Subject: Re: to_timestamp error between postgres version 8.3 and 9.2 In-reply-to: References: Comments: In-reply-to Technical Doubts message dated "Sat, 31 Aug 2013 10:49:12 +0530" Date: Sat, 31 Aug 2013 01:47:00 -0400 Message-ID: <14883.1377928020@sss.pgh.pa.us> X-Pg-Spam-Score: -4.4 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Technical Doubts writes: > insert into registers_info (regid,transid,regdate,canceldate) values > ('reg1',1,to_timestamp('2013-07-24','yyyy-MM-dd > hh24:mi:ss')::TIMESTAMP,to_timestamp('null','yyyy-MM-dd > hh24:mi:ss')::TIMESTAMP); > The above query works fine in Postgres 8.3 version. > But the same query when executed in postgres 9.2 its throwing below error > ERROR: invalid value "null" for "yyyy" > Detail: Value must be an integer. Yup. It was never intended that 'null' would be valid input for to_timestamp, and that's thrown an error since 8.4. See thread here: http://www.postgresql.org/message-id/37ed240d0808291839t21e19956mdfbdc80aeb1b3c19@mail.gmail.com A quick test says that 8.3 and older did this: regression=# select to_timestamp('null','yyyy-MM-dd hh24:mi:ss'); to_timestamp --------------------------- 0001-01-01 00:00:00-05 BC (1 row) which can hardly be considered a sane interpretation of 'null', even if we wanted to accept that input. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin