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 1pGUrN-0005Wz-A5 for pgsql-general@arkaria.postgresql.org; Sat, 14 Jan 2023 00:57:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pGUrL-0003kV-V2 for pgsql-general@arkaria.postgresql.org; Sat, 14 Jan 2023 00:57:23 +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 1pGUrL-0003kM-Kn for pgsql-general@lists.postgresql.org; Sat, 14 Jan 2023 00:57:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGUrJ-0007Xj-Kh for pgsql-general@lists.postgresql.org; Sat, 14 Jan 2023 00:57:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30E0vFHs892689; Fri, 13 Jan 2023 19:57:15 -0500 From: Tom Lane To: Ken Tanzer cc: Adrian Klaver , Sebastien Flaesch , pgsql-general Subject: Re: Intervals and ISO 8601 duration In-reply-to: References: <953416.1673536094@sss.pgh.pa.us> <53c0b4d4-b80a-a35b-ce18-61058794c9bb@aklaver.com> <13f80fd5-6baf-e272-54c7-e72e32280643@aklaver.com> Comments: In-reply-to Ken Tanzer message dated "Fri, 13 Jan 2023 16:28:01 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <892687.1673657835.1@sss.pgh.pa.us> Date: Fri, 13 Jan 2023 19:57:15 -0500 Message-ID: <892688.1673657835@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ken Tanzer writes: > Not really. My original question was: >> [since intervals are stored internally as months, days and microseconds...] >> What Postgres actually stores for an interval is three fields: >> months, days, and microseconds. >> *Is there a way to view/extract this raw data for any given interval?* Given what extract() provides, stored months = years * 12 + months stored days = days stored usec = reconstruct from hours+minutes+seconds+microseconds Perhaps it wouldn't be a bad idea to provide a couple more extract() keywords to make that easier. regards, tom lane