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.94.2) (envelope-from ) id 1rzHJR-002suB-GN for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Apr 2024 14:40:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rzHJO-008tsf-5T for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Apr 2024 14:39:58 +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.94.2) (envelope-from ) id 1rzHJN-008tsX-TG for pgsql-bugs@lists.postgresql.org; Tue, 23 Apr 2024 14:39:57 +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.94.2) (envelope-from ) id 1rzHJL-004GMZ-CC for pgsql-bugs@lists.postgresql.org; Tue, 23 Apr 2024 14:39:56 +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 43NEdrsu3332892; Tue, 23 Apr 2024 10:39:53 -0400 From: Tom Lane To: fcaldasdesou@bloomberg.net cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18445: date_part / extract range for hours do not match documentation In-reply-to: <18445-2bdf6f3c730abe6d@postgresql.org> References: <18445-2bdf6f3c730abe6d@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 23 Apr 2024 10:10:25 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3332890.1713883193.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 23 Apr 2024 10:39:53 -0400 Message-ID: <3332891.1713883193@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > In https://www.postgresql.org/docs/8.1/functions-datetime.html It would be a good idea to look at versions of the documentation that aren't so many years obsolete. 8.1 has been EOL since 2010. > We say that EXTRACT() should return a number between 0-23 for hours What it says now is The hour field (0-23 in timestamps, unrestricted in intervals) (This wording is currently only visible at https://www.postgresql.org/docs/devel/functions-datetime.html#FUNCTIONS-DA= TETIME-EXTRACT but it will propagate into the website's copies of still-maintained branches at our next quarterly updates.) > The function seems to also return 24 in some cases eg: > SELECT date_part('hour', cast('24:00:00.00' as time))::int > Could we update the documentation or modify the function so that it wrap= s 24 > back to 0 hours? That edge case for type "time" is deliberate; see the definition of that type in table 8.9 here: https://www.postgresql.org/docs/devel/datatype-datetime.html I don't really feel a need to clutter the documentation for EXTRACT() still more by mentioning it there, especially since the current wording is not wrong, just silent about that detail. regards, tom lane