Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ftEdg-0000Nb-D6 for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Aug 2018 16:08:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ftEde-0006tX-DX for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Aug 2018 16:08:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ftEde-0006tQ-7W for pgsql-bugs@lists.postgresql.org; Fri, 24 Aug 2018 16:08:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ftEdW-0002lb-76 for pgsql-bugs@lists.postgresql.org; Fri, 24 Aug 2018 16:08:41 +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 w7OG8UJu015478; Fri, 24 Aug 2018 12:08:30 -0400 From: Tom Lane To: infinite77derger@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15351: to_date() function bug In-reply-to: <153512536372.1489.18196536375179237149@wrigleys.postgresql.org> References: <153512536372.1489.18196536375179237149@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Fri, 24 Aug 2018 15:42:43 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15476.1535126910.1@sss.pgh.pa.us> Date: Fri, 24 Aug 2018 12:08:30 -0400 Message-ID: <15477.1535126910@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > All dates, that are less then '04.01.0001', returns in Before Christ (!) > format. Can't reproduce that here ... > Examples: > SELECT to_date('01.12.0000', 'DD.MM.YYYY'); - - converts to 0001-12-01 BC > (Before Christ) > SELECT to_date('01.01.0000', 'DD.MM.YYYY'); - - converts to 0001-01-01 > BC Neither of the above are surprising. There's no year zero in the Gregorian calendar. We could throw an error for that input, perhaps, but what the code chooses to do is interpret it as 1BC. > SELECT to_date('01.01.0001', 'DD.MM.YYYY'); - - converts to 0001-01-01 > BC That would be a bug, I agree, but I can't reproduce it here. I get regression=# SELECT to_date('01.01.0001', 'DD.MM.YYYY'); to_date ------------ 0001-01-01 (1 row) and likewise for your other funny cases. I wonder whether you're using a stock build of Postgres --- or maybe you're running into compiler bugs? Where did you get PG from? > SELECT to_date('', 'DD.MM.YYYY'); - - empty text also converts to > 0001-01-01 BC That seems all right given the interpretation of zeroes. There's probably a market for a version of to_date that's more willing to throw errors for questionable input ... but that's not how to_date itself has traditionally worked. regards, tom lane