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 1pGTiz-0008Go-Hz for pgsql-general@arkaria.postgresql.org; Fri, 13 Jan 2023 23:44:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pGTix-0006Y2-Oi for pgsql-general@arkaria.postgresql.org; Fri, 13 Jan 2023 23:44:39 +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 1pGTiw-0006Xr-Oy for pgsql-general@lists.postgresql.org; Fri, 13 Jan 2023 23:44:39 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGTio-0006nv-QC for pgsql-general@lists.postgresql.org; Fri, 13 Jan 2023 23:44:38 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 6D2185C00A1; Fri, 13 Jan 2023 18:44:27 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 13 Jan 2023 18:44:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1673653467; x= 1673739867; bh=7omQDloFmd9TZrH857SLFqGa3HrS+hnCmgUutG7RKjQ=; b=F Zup65WuFWrPf+pQPA3FiG0XyxVqRhicaY3kbkbPHSxDe+4cJEYnws2IYj5AIB4Vd 7mVTuB+5KUpfLmdc0/wuWMB1UZ4e2/QSX5PEp2jG16mfq1vwQK7mk86Cs9b2HnOi xr3HhP2qHFkpwgoMfB2sLwg8SIez+5npaa9aGkHmlZ1zHoLM+pOfjEjm6ypAk6zJ uOgn4b2ekACcWIK6GBoDHI0oBlIWmaPsW1bXEdhJ9SGYizH6TsR409atmQwALfEP /bYX+Z6j4fb+EFVsdrNd/dCPowSRfSH29jih/cQktYXXVwXJWDPIHS39BaAJ07iY H3H22b0Btjx4DBKUTZmbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1673653467; x= 1673739867; bh=7omQDloFmd9TZrH857SLFqGa3HrS+hnCmgUutG7RKjQ=; b=s v8BKxBsGZu/kvO5r1xeqGq3nzvjXXvN2+geQ6teAbtjO3JOdd2sf6pSibbHA6bUF 9JilYRbKAGm9XqGQO62QYgWqUANUDWyelLEDb73vb2koiMml8rFeZAGOG78iIqY4 cj+BdOda8AAac/tln17gctsWX89cAMQGD+FDe2F0nhzsQAJYruDKY/3qm78xVd7x odj4yoMsyzEgMnbvabbWkD5EV2NvYk/lgrQQ157ToHXv/51rObuSsbPSQHoqzSAp znZr5JbxzngpZblWJxrn9zB4OPoL3qrP1zkre8FoNIFyzD2BtfRytrfgWNbmxjPE DQS6VfTw0wr0bTAOBXGGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleelgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeetleeggeegtdffledvvefgvddtfedugfevhfehgfei geekjeevgffgveefvdeiueenucffohhmrghinheprghgvghntgihqdhsohhfthifrghrvg drohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Jan 2023 18:44:25 -0500 (EST) Message-ID: Date: Fri, 13 Jan 2023 15:44:24 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Intervals and ISO 8601 duration Content-Language: en-US To: Ken Tanzer Cc: Tom Lane , Sebastien Flaesch , pgsql-general References: <953416.1673536094@sss.pgh.pa.us> <53c0b4d4-b80a-a35b-ce18-61058794c9bb@aklaver.com> <13f80fd5-6baf-e272-54c7-e72e32280643@aklaver.com> From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/13/23 15:32, Ken Tanzer wrote: > On Fri, Jan 13, 2023 at 3:03 PM Adrian Klaver > wrote: > > > WITH inters AS ( >      SELECT >          '1 day 2 hours'::interval AS i1, >          '26 hours'::interval AS i2, >          justify_interval('1 day 2 hours'::interval) AS ij1, >          justify_interval('26 hours'::interval) AS ij2 > ) > SELECT >      *, >      to_char(justify_interval(i1),'HH24:MM:SS') AS i1_char, >      to_char(justify_interval(i2),'HH24:MM:SS') AS i2_char, >      i1=i2 AS "Equal?" > >        i1       |    i2    |      ij1       |      ij2       | i1_char > | i2_char  | Equal? > ----------------+----------+----------------+----------------+----------+----------+-------- >   1 day 02:00:00 | 26:00:00 | 1 day 02:00:00 | 1 day 02:00:00 | > 02:00:00 > | 02:00:00 | t > > > I'm not quite sure what this is meant to convey.  Maybe justify_hours > and justify_days will return something that uniquely maps to the raw > data, and maybe it doesn't (I can't figure that out!).  But then there's > still no justify_seconds or something that would get at the raw > microseconds being stored. > > And I could be wrong, but it seems like you were aiming towards making > these two intervals the same.  I was trying to zero in on the > opposite--what is it that makes them different (not identical), and how > to access that information.  I was assuming that if they were not This: WITH inters AS ( SELECT '1 day 2 hours'::interval AS i1, '26 hours'::interval AS i2 ) SELECT i1=i2 AS "Equal?" FROM inters; say the intervals are equal. If I am following what you want is to_char(,'HH24:MM:SS') to be equal, correct? > identical, the internal representation in Months, Days and Microseconds > must be different--maybe that assumption is not valid.  And maybe there > is currently no way to get that raw representation.  If that's the case, > so be it, although I might then put in a small plug for it as a feature > request. :) (*) > > Cheers, > Ken > > (*) These are probably bad suggestions, but something like... > >      EXTRACT ( (RAWHOURS|RAWDAYS|RAWMICROSECONDS) ... ? >      Or a function RAWEXTRACT( HOURS|DAYS|MICROSECONDS ) ? > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > > > > -- > AGENCY Software > A Free Software data system > By and for non-profits > /http://agency-software.org/ / > /https://demo.agency-software.org/client > / > ken.tanzer@agency-software.org > (253) 245-3801 > > Subscribe to the mailing list >  to > learn more about AGENCY or > follow the discussion. -- Adrian Klaver adrian.klaver@aklaver.com