From: Nathan Bossart <nathandbossart@gmail.com>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: qubzen@gmail.com, pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17496: to_char function resets if interval exceeds 23 hours 59 minutes
Date: Tue, 24 May 2022 13:11:45 -0700
Message-ID: <20220524201145.GA1253717@nathanxps13> (raw)
In-Reply-To: <CAMkU=1xx4jXYnTdbfxcrzpiDYPeS6fybXtns3rBP2ticpKASAQ@mail.gmail.com>
References: <17496-147d18008f247af9@postgresql.org>
<CAMkU=1xx4jXYnTdbfxcrzpiDYPeS6fybXtns3rBP2ticpKASAQ@mail.gmail.com>
On Tue, May 24, 2022 at 03:55:49PM -0400, Jeff Janes wrote:
> On Tue, May 24, 2022, 3:23 PM PG Bug reporting form <noreply@postgresql.org>
>> to_char function resets if interval exceeds 23 hours 59 minutes found at:
>>
>> https://www.postgresql.org/docs/current/functions-formatting.html#FUNCTIONS-FORMATTING-TABLE
>>
>> Tested for both 13 and 14 versions. Check here:
>>
>> https://dbfiddle.uk/?rdbms=postgres_14&fiddle=31f5d8b7e8dbf855e1907e6e8f01d5cf
>
>
> I don't see how this is a bug. You told it not to display the days or
> higher units, so it doesn't.
The documentation for this function indicates HH24 can output hour values
higher than 23∴
<function>to_char(interval)</function> formats <literal>HH</literal> and
<literal>HH12</literal> as shown on a 12-hour clock, for example zero hours
and 36 hours both output as <literal>12</literal>, while <literal>HH24</literal>
outputs the full hour value, which can exceed 23 in
an <type>interval</type> value.
I see different results depending on how I define the interval:
postgres=# select to_char(INTERVAL '1 day', 'HH24:MI');
to_char
---------
00:00
(1 row)
postgres=# select to_char(INTERVAL '24h', 'HH24:MI');
to_char
---------
24:00
(1 row)
The example provided is more like the former (no hour value), because
"timestamp - timestamp" converts 24-hour intervals into days. In general,
I agree that this probably not a bug. You probably want to ask to_char()
to display the days as well..
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
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: nathandbossart@gmail.com, jeff.janes@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17496: to_char function resets if interval exceeds 23 hours 59 minutes
In-Reply-To: <20220524201145.GA1253717@nathanxps13>
* 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