Search before asking
Version
0.15
What's Wrong?
# doris 0.15# timestampdiff between 1981-09-11 and 2022-04-28 should be 40 yearsSELECT TIMESTAMPDIFF(YEAR,DATE('1981-09-11'),'2022-04-28') AS`date-str`,
TIMESTAMPDIFF(YEAR,'1981-09-11','2022-04-28') AS`str-str`,
TIMESTAMPDIFF(YEAR,DATE('1981-09-11'),DATE('2022-04-28')) AS`date-date`,
TIMESTAMPDIFF(YEAR,'1981-09-11',DATE('2022-04-28')) AS`str-date`# while the result is date-str str-str date-date str-date41404141# timestampdiff between 1981-04-11 and 2022-04-28 should be 41 yearsSELECT
TIMESTAMPDIFF(YEAR,DATE('1981-09-11'),'2022-04-28') AS`date-str`,
TIMESTAMPDIFF(YEAR,'1981-09-11','2022-04-28') AS`str-str`,
TIMESTAMPDIFF(YEAR,DATE('1981-04-11'),DATE('2022-04-28')) AS`date-date`,
TIMESTAMPDIFF(YEAR,'1981-04-11',DATE('2022-04-28')) AS`str-date`# while the result is date-str str-str date-date str-date41404141What You Expected?
timestampdiff between 1981-09-11 and 2022-04-28 should be 40 year
timestampdiff between 1981-04-11 and 2022-04-28 should be 41 year
Anything Else?
This also happens when unit is MONTH !
And it even get different result using TIMESTAMP(expr) instead of DATE(expr)
Are you willing to submit PR?
Code of Conduct
Search before asking
Version
0.15
What's Wrong?
What You Expected?
timestampdiff between 1981-09-11 and 2022-04-28 should be 40 year
timestampdiff between 1981-04-11 and 2022-04-28 should be 41 year
Anything Else?
This also happens when
unitisMONTH!And it even get different result using
TIMESTAMP(expr)instead ofDATE(expr)Are you willing to submit PR?
Code of Conduct