Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1miOfu-0008Kb-VB for pgsql-general@arkaria.postgresql.org; Wed, 03 Nov 2021 22:24:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1miOft-0001PN-3B for pgsql-general@arkaria.postgresql.org; Wed, 03 Nov 2021 22:24:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1miOfs-0001PE-QB for pgsql-general@lists.postgresql.org; Wed, 03 Nov 2021 22:24:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1miOfm-0005Sy-Jn for pgsql-general@lists.postgresql.org; Wed, 03 Nov 2021 22:24:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1A3MNs8X265332; Wed, 3 Nov 2021 18:23:54 -0400 From: Tom Lane To: Adrian Klaver cc: Bryn Llewellyn , pgsql-general list Subject: Re: to_date() and to_timestamp() with negative years In-reply-to: References: <138332.1635962086@sss.pgh.pa.us> <08E63AD5-8E6D-4140-AE1C-9DC22324A287@yugabyte.com> <72204b8f-41b2-0004-b09b-842f8c57477f@aklaver.com> <0B75398B-91CC-4074-B77A-390AA157685B@yugabyte.com> Comments: In-reply-to Adrian Klaver message dated "Wed, 03 Nov 2021 15:14:49 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <265330.1635978234.1@sss.pgh.pa.us> Date: Wed, 03 Nov 2021 18:23:54 -0400 Message-ID: <265331.1635978234@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Adrian Klaver writes: > Haven't had time to work through what the above is actually doing. I think the first two are explained by 489c9c340: Also, arrange for the combination of a negative year and an explicit "BC" marker to cancel out and produce AD. This is how the negative-century case works, so it seems sane to do likewise. The last two look like a parsing issue: with no field separator (nope, the space doesn't count), the code is taking the dash as a field separator. regards, tom lane