pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Sebastien Flaesch <sebastien.flaesch@4js.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Intervals and ISO 8601 duration
Date: Fri, 13 Jan 2023 15:44:24 -0800
Message-ID: <d66d3ff9-2e85-253f-4637-cc488954f760@aklaver.com> (raw)
In-Reply-To: <CAD3a31XM7TczB9aY2AA3Ld7PFLuwLra3dxqPu2zGd5F0Kb9w2Q@mail.gmail.com>
References: <AM9P191MB1286AD77B5FBAF4640E7274AB0FD9@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM>
	<953416.1673536094@sss.pgh.pa.us>
	<CAD3a31XW8iqrZ+uB7if+YUgRjk_=9YQOJRJVBc5__yGRsgypQA@mail.gmail.com>
	<53c0b4d4-b80a-a35b-ce18-61058794c9bb@aklaver.com>
	<CAD3a31UP79wrZZTRFtP4sPvgOy7TZg2v6FmPzXYdAAnaOdnuiQ@mail.gmail.com>
	<13f80fd5-6baf-e272-54c7-e72e32280643@aklaver.com>
	<CAD3a31XM7TczB9aY2AA3Ld7PFLuwLra3dxqPu2zGd5F0Kb9w2Q@mail.gmail.com>

On 1/13/23 15:32, Ken Tanzer wrote:
> On Fri, Jan 13, 2023 at 3:03 PM Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> 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(<interval>,'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 <mailto:adrian.klaver@aklaver.com>
> 
> 
> 
> -- 
> AGENCY Software
> A Free Software data system
> By and for non-profits
> /http://agency-software.org/ <http://agency-software.org/>/
> /https://demo.agency-software.org/client 
> <https://demo.agency-software.org/client>/
> ken.tanzer@agency-software.org <mailto:ken.tanzer@agency-software.org>
> (253) 245-3801
> 
> Subscribe to the mailing list 
> <mailto:agency-general-request@lists.sourceforge.net?body=subscribe> to
> learn more about AGENCY or
> follow the discussion.

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (24+ messages)  latest in thread

Message-ID: <d66d3ff9-2e85-253f-4637-cc488954f760@aklaver.com>
Permalink:  ../d66d3ff9-2e85-253f-4637-cc488954f760@aklaver.com/
Also on:    postgresql.org/message-id/d66d3ff9-2e85-253f-4637-cc488954f760@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, ken.tanzer@gmail.com, tgl@sss.pgh.pa.us, sebastien.flaesch@4js.com
  Subject: Re: Intervals and ISO 8601 duration
  In-Reply-To: <d66d3ff9-2e85-253f-4637-cc488954f760@aklaver.com>
  References: <AM9P191MB1286AD77B5FBAF4640E7274AB0FD9@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM> <953416.1673536094@sss.pgh.pa.us> <CAD3a31XW8iqrZ+uB7if+YUgRjk_=9YQOJRJVBc5__yGRsgypQA@mail.gmail.com> <53c0b4d4-b80a-a35b-ce18-61058794c9bb@aklaver.com> <CAD3a31UP79wrZZTRFtP4sPvgOy7TZg2v6FmPzXYdAAnaOdnuiQ@mail.gmail.com> <13f80fd5-6baf-e272-54c7-e72e32280643@aklaver.com> <CAD3a31XM7TczB9aY2AA3Ld7PFLuwLra3dxqPu2zGd5F0Kb9w2Q@mail.gmail.com> <d66d3ff9-2e85-253f-4637-cc488954f760@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox