Re: Intervals and ISO 8601 duration

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Sebastien Flaesch <sebastien(dot)flaesch(at)4js(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Intervals and ISO 8601 duration
Date: 2023-01-13 22:51:31
Message-ID: CAD3a31UP79wrZZTRFtP4sPvgOy7TZg2v6FmPzXYdAAnaOdnuiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 13, 2023 at 2:41 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> > (I'm asking because of an issue that came up about intervals that were
> > "equal but not identical.")
>
> 1) Can you provide an example?
>
>
Here's an example. Note that they come out formatted differently with
to_char, but evaluate as equal. The explanation(1) was that they were
Equal but not Identical. I was thinking getting the raw data about how
they are stored would get at the identicality issue:

WITH inters AS (
SELECT
'1 day 2 hours'::interval AS i1,
'26 hours'::interval AS i2
)
SELECT
*,
to_char(i1,'HH24:MM:SS') AS i1_char,
to_char(i2,'HH24:MM:SS') AS i2_char,
i1=i2 AS "Equal?"
FROM inters;

i1 | i2 | i1_char | i2_char | Equal?
----------------+----------+----------+----------+--------
1 day 02:00:00 | 26:00:00 | 02:00:00 | 26:00:00 | t

(1)
https://www.postgresql.org/message-id/flat/CAJKTcg9jLfH%2B-v8TS2gV%3DvZzqjLZ5cYyMVUtGxwyRitER5htMg%40mail.gmail.com

Cheers,
Ken

>
> >
> > Cheers,
> > Ken
> >
> >
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)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(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-01-13 23:03:39 Re: Intervals and ISO 8601 duration
Previous Message David G. Johnston 2023-01-13 22:49:28 Re: Intervals and ISO 8601 duration