Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wFwAF-005ixK-0F for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Apr 2026 15:40:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFwAD-002O3R-0K for pgsql-bugs@arkaria.postgresql.org; Thu, 23 Apr 2026 15:40:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wFwAC-002O2s-2h for pgsql-bugs@lists.postgresql.org; Thu, 23 Apr 2026 15:40:24 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wFwAA-00000002R7c-2rDx for pgsql-bugs@lists.postgresql.org; Thu, 23 Apr 2026 15:40:23 +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 63NFeEGG1444610; Thu, 23 Apr 2026 11:40:14 -0400 From: Tom Lane To: Daniel Gustafsson cc: Michael Paquier , Ayush Tiwari , pgsql-bugs@lists.postgresql.org Subject: Re: to_date()/to_timestamp() silently accept month=0 and day=0 In-reply-to: References: Comments: In-reply-to Daniel Gustafsson message dated "Thu, 23 Apr 2026 10:11:47 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1444608.1776958814.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 23 Apr 2026 11:40:14 -0400 Message-ID: <1444609.1776958814@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: >> On 23 Apr 2026, at 09:57, Michael Paquier wrote: >> Perhaps we could consider strengthening such inputs on HEAD once v20 >> opens for business? It would be really a scary thing to backpatch, >> still a major release is a different thing. > This could definitely not be backpatched IMO, a quick check in v14 shows= the > same behaviour. The gregorian calendar goes from BC1 to AD1 and does no= t > define a year 0, to_date('0000','YYYY') correctly returns year 0001, han= dling > months/days in the same way at least makes it consistent (though I didn'= t scour > the archives to see if it was intentionally done like that). Looking at the code, I think it intentionally interprets zero as "missing data". See for example the stanza at formatting.c:4650ff where tm_mon and tm_mday can be backfilled from a DDD field. I'm disinclined to change the behavior around this; you're far more likely to get complaints than kudos. regards, tom lane