gpt4 book ai didi

mysql - 如何将负时差值设置为零

转载 作者:行者123 更新时间:2023-11-29 21:33:25 26 4
gpt4 key购买 nike

如果时差结果为负数,如何将其设置为零

select TIMEDIFF('2016-01-29 12:28:18','2016-01-29 19:27:51') as diff;
<小时/>

| -06:59:33 |

最佳答案

试试这个:

select if((time_to_sec(TIMEDIFF('2016-01-29 12:28:18','2016-01-29 19:27:51'))/3600) < 0,0,TIMEDIFF('2016-01-29 12:28:18','2016-01-29 19:27:51')) as diff;

关于mysql - 如何将负时差值设置为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35079574/

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