MySQL的时间差函数TIMESTAMPDIFF、DATEDIFF

时间:2023-01-27 00:43:53

MySQL的时间差函数TIMESTAMPDIFF、DATEDIFF

需要用MySQL计算时间差函数TIMESTAMPDIFF、DATEDIFF

 

MySQL的时间差函数TIMESTAMPDIFF、DATEDIFFMySQL的时间差函数TIMESTAMPDIFF、DATEDIFFMySQL的时间差函数TIMESTAMPDIFF、DATEDIFF
--0
select datediff(now(), now());

--2
select datediff('2015-04-22 23:59:00', '2015-04-20 00:00:00');

--2
select datediff('2015-04-22 00:00:00', '2015-04-20 23:59:00');

--1
select TIMESTAMPDIFF(DAY, '2015-04-20 23:59:00', '2015-04-22 00:00:00');

--2
select TIMESTAMPDIFF(DAY, '2015-04-20 00:00:00', '2015-04-22 00:00:00');

--2
select TIMESTAMPDIFF(DAY, '2015-04-20 00:00:00', '2015-04-22 12:00:00');

--2
select TIMESTAMPDIFF(DAY, '2015-04-20 00:00:00', '2015-04-22 23:59:00');

--71
select TIMESTAMPDIFF(HOUR, '2015-04-20 00:00:00', '2015-04-22 23:00:00');

--4260
select TIMESTAMPDIFF(MINUTE, '2015-04-20 00:00:00', '2015-04-22 23:00:00');
MySQL的时间差函数TIMESTAMPDIFF、DATEDIFF
MySQL的时间差函数TIMESTAMPDIFF、DATEDIFF