-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
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小时