(based on a find by Ruud van Tol, and several Twitter contributions)
Ruud commented on our DST discussion
with
mysql> SELECT
'2019-02-28 12:34:56'+ INTERVAL 1 YEAR + INTERVAL 1 DAY as a,
'2019-02-28 12:34:56'+ INTERVAL 1 DAY + INTERVAL 1 YEAR as b\G
a: 2020-02-29 12:34:56
b: 2020-03-01 12:34:56
2019 is a year before a leap year. Adding (left to right) a year
brings us to 2020-02-28, and then adding a day makes
this 2020-02-29, because it’s a leap year.
On the other hand, adding a day first makes it
2019-03-01, and then adding a year makes it
2020-03-01, a different result.
Clearly, addition is not commutative on dates, and having a two step interval addition is breaking expectations here.
…
[Read more]