Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDYBP-0007JL-U0 for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Jul 2022 21:21:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDYBO-0002xb-OZ for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Jul 2022 21:21:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDYBO-0002xS-Gj for pgsql-bugs@lists.postgresql.org; Mon, 18 Jul 2022 21:21:38 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDYBH-00019S-OR for pgsql-bugs@lists.postgresql.org; Mon, 18 Jul 2022 21:21:38 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1oDYBG-0068MR-56; Mon, 18 Jul 2022 17:21:30 -0400 Date: Mon, 18 Jul 2022 17:21:30 -0400 From: Bruce Momjian To: Kyotaro Horiguchi Cc: 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 Message-ID: References: <20220524201145.GA1253717@nathanxps13> <20220715.165835.1978703631960901210.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220715.165835.1978703631960901210.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jul 15, 2022 at 04:58:35PM +0900, Kyotaro Horiguchi wrote: > At Thu, 14 Jul 2022 17:57:32 -0400, Bruce Momjian 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 https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson