On Sat, Nov 19, 2022 at 2:39 AM Alban Hertroys <haram...@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 *http://agency-software.org/ <http://agency-software.org/>* *https://demo.agency-software.org/client <https://demo.agency-software.org/client>* ken.tan...@agency-software.org (253) 245-3801 Subscribe to the mailing list <agency-general-requ...@lists.sourceforge.net?body=subscribe> to learn more about AGENCY or follow the discussion.