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 1ntask-0001fD-Jl for pgsql-bugs@arkaria.postgresql.org; Tue, 24 May 2022 20:11:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntasj-0000IA-Ez for pgsql-bugs@arkaria.postgresql.org; Tue, 24 May 2022 20:11:53 +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 1ntasj-0000I1-6p for pgsql-bugs@lists.postgresql.org; Tue, 24 May 2022 20:11:53 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ntasg-0003iq-0K for pgsql-bugs@lists.postgresql.org; Tue, 24 May 2022 20:11:52 +0000 Received: by mail-pg1-x534.google.com with SMTP id x12so17170714pgj.7 for ; Tue, 24 May 2022 13:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=bzSlnq/L5WokRPFamdkLpeffE11kH3sHzjsZu/zt9Fk=; b=XqSD1lLaDk8glJZtbFL2yQASnTgbdSIExA6oTKM8N5ESUCrIiZinOnn4khzSZB0Hvh mjuWzP7L006mC6ATFvrBrk5fFFKzM4XxeKC+bbOOl0kQTb10TrQcqeCVKs7mCbbA5s+v yD5nB5nQl9caGiTGqyrImI6x4Aa572BdQj3Rc4cw1RFR/tMVn2SGR/soQxjeOcDY+UKh zpObiTJPFMq6lxeBzuHwd4MUmnhrSWxkaNQxD0AS1MogfsQBmqHcChc5ixoUZ1zQ3aGh 699hH9NYcjceFYPQ+WHtH6AtrV64qgLzL9CnYfz2U0Lwihssf4fJnjD3L8WsmpBOtI2G zM+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=bzSlnq/L5WokRPFamdkLpeffE11kH3sHzjsZu/zt9Fk=; b=C8YGDCdcdZnwmKFnyvU+Ogemw0t6VMewv7I9Vd3yfKVzPgsF4hBGEYz16VQAeKq55y N/i63UAZW0T9mUwS+k+KNATjs6RsPRVyrrxvWCqCnRCJPhg33LphcLj2LffI/kyqje/u Uijj9bIJMAxr/aHHkB5mPZmqFPwoI08CfXN+xlViPCWJRY0+oWAQ5PyyPfeFLs3v4jCE V0lT7j6YFoR2d4l0yA+2Hj45XPzo8r85UkXi5Vcd5R4L4KuvZeJHuGXvefL4+vEJ1r+F To+OAiMflbV8jUsk+7sPvV8BtlYGLMLBkOuD7s6UNVC/Qq9T36jqoyTyVqJJmIKpKdpV 4m0A== X-Gm-Message-State: AOAM532YCr2IBpgyTXpbT/SjMiavD8OCcrCWLA0iUBhRe9o8Nf1uCrxc qRB3df9w23kScwmDrXzvPXQ= X-Google-Smtp-Source: ABdhPJwiuBnrpgank28N6ChiJix0VFHOOVQvNFQLhWIxGjWY324GNAgO0QBB6hQVVYGBvNTw6PKukw== X-Received: by 2002:aa7:88d5:0:b0:518:8ef4:f378 with SMTP id k21-20020aa788d5000000b005188ef4f378mr15830522pff.2.1653423107960; Tue, 24 May 2022 13:11:47 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id z29-20020aa7959d000000b005183434ec86sm9812007pfj.135.2022.05.24.13.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 13:11:47 -0700 (PDT) Date: Tue, 24 May 2022 13:11:45 -0700 From: Nathan Bossart To: Jeff Janes Cc: qubzen@gmail.com, pgsql-bugs Subject: Re: BUG #17496: to_char function resets if interval exceeds 23 hours 59 minutes Message-ID: <20220524201145.GA1253717@nathanxps13> References: <17496-147d18008f247af9@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 >> 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∴ to_char(interval) formats HH and HH12 as shown on a 12-hour clock, for example zero hours and 36 hours both output as 12, while HH24 outputs the full hour value, which can exceed 23 in an interval 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