Search Postgresql Archives

Re: Duda sobre como imprimir un campo INTERVAL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Sat, Nov 19, 2022 at 2:39 AM Alban Hertroys <haramrae@xxxxxxxxx> 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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux