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 1ozohi-0005ak-Jo for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Nov 2022 00:42:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ozohh-0007WS-Bb for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Nov 2022 00:42:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ozohh-0007WI-3A for pgsql-bugs@lists.postgresql.org; Tue, 29 Nov 2022 00:42:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ozohe-0002qQ-Ll for pgsql-bugs@lists.postgresql.org; Tue, 29 Nov 2022 00:42:28 +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 2AT0gOcg778132; Mon, 28 Nov 2022 19:42:24 -0500 From: Tom Lane To: rk@marksim.org cc: pgsql-bugs@lists.postgresql.org Subject: Re: daterange() is ignoring 3rd boundaries argument In-reply-to: References: Comments: In-reply-to Robert KOFLER message dated "Tue, 29 Nov 2022 00:50:51 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <778130.1669682544.1@sss.pgh.pa.us> Date: Mon, 28 Nov 2022 19:42:24 -0500 Message-ID: <778131.1669682544@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert KOFLER writes: > select daterange('2022-11-01'::date, '2023-01-31'::date, '()') > returns > [2022-11-02,2023-01-31) which is deafult of [) > instead of > (2022-11-02,2023-01-31) It's not "ignoring" the endpoint argument, because you get different results from regression=# select daterange('2022-11-01'::date, '2023-01-31'::date, '()'); daterange ------------------------- [2022-11-02,2023-01-31) (1 row) regression=# select daterange('2022-11-01'::date, '2023-01-31'::date, '[)'); daterange ------------------------- [2022-11-01,2023-01-31) (1 row) regression=# select daterange('2022-11-01'::date, '2023-01-31'::date, '[]'); daterange ------------------------- [2022-11-01,2023-02-01) (1 row) As explained somewhere in the fine manual (though not in the exact spot you're reading), for ranges over discrete types such as dates, we prefer to normalize to the '[)' endpoint conventions. That's not possible for continuous types such as floats or timestamps, so in those cases we leave the endpoint specs alone. If that really annoys you, you can make your own range type over dates that lacks a "canonical" function. But it's not a bug; it's operating as intended. regards, tom lane