Skip to content

【bug】timestampdiff 在某个情况下计算有误 #4618

Description

@li-ang-666

timestampdiff(DAY,时间1,时间2)
判断 -1,0,1 ,2 .. 的依据,在MySQL中是24小时,在Doris中也是,但是某种情况下,出现的结果是错误的:

时间2 和 时间1 是同一天 && 时间2 小于 时间1

此时会直接被判定为-1

MySQL [bi_production]> select timestampdiff(DAY,'2020-02-02 11:11:11','2020-02-02 11:11:11');
+------------------------------------------------------------------+
| timestampdiff(DAY, '2020-02-02 11:11:11', '2020-02-02 11:11:11') |
+------------------------------------------------------------------+
| 0
+------------------------------------------------------------------+
1 row in set (0.01 sec)
--正确

MySQL [bi_production]> select timestampdiff(DAY,'2020-02-02 11:11:11','2020-02-02 10:10:10');
+------------------------------------------------------------------+
| timestampdiff(DAY, '2020-02-02 11:11:11', '2020-02-02 10:10:10') |
+------------------------------------------------------------------+
| -1
+------------------------------------------------------------------+
1 row in set (0.00 sec)
--错误,虽然时间小于,但是没有小于超过24小时

MySQL [bi_production]> select timestampdiff(DAY,'2020-02-02 11:11:11','2020-02-01 12:12:12');
+------------------------------------------------------------------+
| timestampdiff(DAY, '2020-02-02 11:11:11', '2020-02-01 12:12:12') |
+------------------------------------------------------------------+
| 0
+------------------------------------------------------------------+
1 row in set (0.01 sec)
--正确,虽然时间小于,但是没有小于超过24小时

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions