Re: Duda sobre como imprimir un campo INTERVAL

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: Alban Hertroys <haramrae(at)gmail(dot)com>
Cc: Alejandro Baeza Rangel <jlabaezarangel(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Duda sobre como imprimir un campo INTERVAL
Date: 2022-11-19 20:37:43
Message-ID: CAD3a31VET+Z7D=9hsa2=1FuB141OoG9F_vzF=hHa0eSPgBOK2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Nov 19, 2022 at 2:39 AM Alban Hertroys <haramrae(at)gmail(dot)com> wrote:

>
>
> > don't fully understand it. But what really confuses me is the example
> below. How can these two intervals be equal and still yield different
> output in the to_char function? And as a practical matter, and for the OPs
> question, how can you convert from one to the other of these "equal" values?
> >
> > 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
> >
>
> Those intervals are not identical. I think the reasoning is that due to
> DST changes, ‘1 day 2 hours’ is more specific than its conversion to ’26
> hours’ (or 25 or 27 at DST change).

Thanks. I could understand that they're not identical. But then what's
going on where Postgres evaluates them as equal? (i1=i2 above.) Are the
two intervals getting cast or converted to something else before they are
compared, with whatever makes them non-identical getting lost in the
conversion?

Cheers,
Ken
--
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 Tom Lane 2022-11-19 22:22:25 Re: Duda sobre como imprimir un campo INTERVAL
Previous Message Alban Hertroys 2022-11-19 10:39:43 Re: Duda sobre como imprimir un campo INTERVAL