From: Bruce Momjian <bruce@momjian.us>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: nathandbossart@gmail.com
Cc: jeff.janes@gmail.com
Cc: qubzen@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17496: to_char function resets if interval exceeds 23 hours 59 minutes
Date: Mon, 18 Jul 2022 17:21:30 -0400
Message-ID: <YtXO2jMXxIRlHJHb@momjian.us> (raw)
In-Reply-To: <20220715.165835.1978703631960901210.horikyota.ntt@gmail.com>
References: <CAMkU=1xx4jXYnTdbfxcrzpiDYPeS6fybXtns3rBP2ticpKASAQ@mail.gmail.com>
<20220524201145.GA1253717@nathanxps13>
<YtCRTLYoAgGcIenX@momjian.us>
<20220715.165835.1978703631960901210.horikyota.ntt@gmail.com>
On Fri, Jul 15, 2022 at 04:58:35PM +0900, Kyotaro Horiguchi wrote:
> At Thu, 14 Jul 2022 17:57:32 -0400, Bruce Momjian <bruce@momjian.us> wrote in
> > On Tue, May 24, 2022 at 01:11:45PM -0700, Nathan Bossart wrote:
> > > 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..
>
> On the other hand, "interval + interval" doesn't convert hours into
> days. I expected the math to do normalization.
>
> select INTERVAL '1 day 15hour' + interval '2 day 15 hour';
> ?column?
> -----------------
> 3 days 30:00:00
>
> Is there any means to control over normalization?
Sure, justify_hours():
SELECT INTERVAL '1 day 15hour' + interval '2 day 15 hour';
?column?
-----------------
3 days 30:00:00
SELECT justify_hours(INTERVAL '1 day 15hour' + interval '2 day 15
hour');
justify_hours
-----------------
4 days 06:00:00
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Indecision is a decision. Inaction is an action. Mark Batterson
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: bruce@momjian.us, horikyota.ntt@gmail.com, nathandbossart@gmail.com, jeff.janes@gmail.com, qubzen@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: <YtXO2jMXxIRlHJHb@momjian.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