gpt4 book ai didi

MySQL datediff 奇怪的结果

转载 作者:行者123 更新时间:2023-11-29 01:55:44 24 4
gpt4 key购买 nike

我得到 datediff 函数的奇怪结果。对于不同和相同的时间戳为零?

select datediff('2015-04-25 20:37:45','2015-04-25 05:20:00');
+-------------------------------------------------------+
| datediff('2015-04-25 20:37:45','2015-04-25 05:20:00') |
+-------------------------------------------------------+
| 0 |
+-------------------------------------------------------+

select datediff('2015-04-25 20:37:45','2015-04-25 20:37:45');
+-------------------------------------------------------+
| datediff('2015-04-25 20:37:45','2015-04-25 20:37:45') |
+-------------------------------------------------------+
| 0 |
+-------------------------------------------------------+

最佳答案

datediff 将对日期进行计算并找到天数差异,但是你可以使用 timestampdiff对于不同的差异,例如 hourmin

mysql> select timestampdiff(hour,'2015-04-25 05:20:00','2015-04-25 20:37:45') as hour;
+------+
| hour |
+------+
| 15 |
+------+
1 row in set (0.00 sec)

关于MySQL datediff 奇怪的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29869156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com