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 1jK2M2-00073C-TT for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2020 16:06:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jK2M1-00073F-Pi for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2020 16:06:05 +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 1jK2M1-000738-Jg for pgsql-bugs@lists.postgresql.org; Thu, 02 Apr 2020 16:06:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK2Lz-0004Pw-Co for pgsql-bugs@lists.postgresql.org; Thu, 02 Apr 2020 16:06:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 032G5x8d018561; Thu, 2 Apr 2020 12:05:59 -0400 From: Tom Lane To: iomihai@hotmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16338: casting interval '24h' to time returns '00:00:00' instead of '24:00:00' In-reply-to: <16338-b198c8cc2395ba5f@postgresql.org> References: <16338-b198c8cc2395ba5f@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 02 Apr 2020 15:55:18 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18559.1585843559.1@sss.pgh.pa.us> Date: Thu, 02 Apr 2020 12:05:59 -0400 Message-ID: <18560.1585843559@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > While casting intervals to time I noticed interval '24h' casts to '00:00:00' > time rather than '24:00:00' > Casting first to text or varchar then to time works as expected > select (interval '24h')::time; => '00:00:00' > select (interval '24h')::text::time => '24:00:00'; > I experienced this in PostgreSQL 9 -12 . > Is this a bug or is this how it is supposed to work? Interval-to-time casts take the interval modulo 24 hours, so I'd say this is expected. regression=# select '40:00:01'::interval::time; time ---------- 16:00:01 (1 row) Note that time itself would refuse to store a value larger than 24hr. regards, tom lane