Re: Duda sobre como imprimir un campo INTERVAL
От | Ken Tanzer |
---|---|
Тема | Re: Duda sobre como imprimir un campo INTERVAL |
Дата | |
Msg-id | CAD3a31VET+Z7D=9hsa2=1FuB141OoG9F_vzF=hHa0eSPgBOK2A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Duda sobre como imprimir un campo INTERVAL (Alban Hertroys <haramrae@gmail.com>) |
Ответы |
Re: Duda sobre como imprimir un campo INTERVAL
|
Список | pgsql-general |
On Sat, Nov 19, 2022 at 2:39 AM Alban Hertroys <haramrae@gmail.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
(253) 245-3801
learn more about AGENCY or
follow the discussion.
В списке pgsql-general по дате отправления: