pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: fcaldasdesou@bloomberg.net
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18445: date_part / extract range for hours do not match documentation
Date: Tue, 23 Apr 2024 10:39:53 -0400
Message-ID: <3332891.1713883193@sss.pgh.pa.us> (raw)
In-Reply-To: <18445-2bdf6f3c730abe6d@postgresql.org>
References: <18445-2bdf6f3c730abe6d@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> 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-DATETIME-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 wraps 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





view thread (7+ messages)  latest in thread

Message-ID: <3332891.1713883193@sss.pgh.pa.us>
Permalink:  ../3332891.1713883193@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3332891.1713883193@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, fcaldasdesou@bloomberg.net, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18445: date_part / extract range for hours do not match documentation
  In-Reply-To: <3332891.1713883193@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox