BUG #18445: date_part / extract range for hours do not match documentation

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: fcaldasdesou(at)bloomberg(dot)net
Subject: BUG #18445: date_part / extract range for hours do not match documentation
Date: 2024-04-23 10:10:25
Message-ID: 18445-2bdf6f3c730abe6d@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18445
Logged by: Filipe Caldas
Email address: fcaldasdesou(at)bloomberg(dot)net
PostgreSQL version: 14.11
Operating system: Linux (RHEL 8)
Description:

In https://www.postgresql.org/docs/8.1/functions-datetime.html

We say that EXTRACT() should return a number between 0-23 for hours

hour
The hour field (0 - 23)
SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 20:38:40');
Result: 20

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 wraps 24
back to 0 hours?
Thanks

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tender Wang 2024-04-23 11:14:04 Re: BUG #18377: Assert false in "partdesc->nparts >= pinfo->nparts", fileName="execPartition.c", lineNumber=1943
Previous Message Kostiantyn Tomakh 2024-04-23 09:58:21 Fwd: BUG #18433: Logical replication timeout