-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
the function of timediff has errors,such as boundary and type
the list of errors is:
1、select timediff(CAST('1944-02-25 00:00:00' as datetime), CAST('1944-2-26' as datetime));
+----------------------------------------------------------------------------------+
| timediff(CAST('1944-02-25 00:00:00' AS DATETIME), CAST('1944-2-26' AS DATETIME)) |
+----------------------------------------------------------------------------------+
| 00:00:00 |
+----------------------------------------------------------------------------------+
except:
+----------------------------------------------------------------------------------+
| timediff(CAST('1944-02-25 00:00:00' as datetime), CAST('1944-2-26' as datetime)) |
+----------------------------------------------------------------------------------+
| -24:00:00 |
+----------------------------------------------------------------------------------+
1 row in set (0.47 sec)
2、boundary
SELECT TIMEDIFF('2019-01-01 00:00:00', '2009-01-01 00:00:00');
+--------------------------------------------------------+
| timediff('2019-01-01 00:00:00', '2009-01-01 00:00:00') |
+--------------------------------------------------------+
| 87648:00:00 |
+---------------------------
except:
SELECT TIMEDIFF('2019-01-01 00:00:00', '2009-01-01 00:00:00');
+--------------------------------------------------------+
| TIMEDIFF('2019-01-01 00:00:00', '2009-01-01 00:00:00') |
+--------------------------------------------------------+
| 838:59:59 |
+--------------------------------------------------------+