直接运行sql 看结果
-- mysql 时间计算函数
-- 函数 TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)
select TIMESTAMPDIFF(DAY, '2022-02-20 23:59:00', '2022-02-22 00:00:00');
select TIMESTAMPDIFF(HOUR, '2022-02-20 23:59:00', '2022-02-22 00:00:00');
select TIMESTAMPDIFF(MINUTE, '2022-02-20 23:59:00', '2022-02-22 00:00:00');
select TIMESTAMPDIFF(SECOND, '2022-02-20 23:59:00', '2022-02-22 00:00:00');
-- 函数 DATEDIFF(expr1,expr2)
select DATEDIFF( '2022-02-20 23:59:00', '2022-02-22 00:00:00');
-- 函数 TIMEDIFF(expr1,expr2)
select TIMEDIFF( '2022-02-20 23:59:00', '2022-02-22 00:00:00');