如何以格式计算两个日期之间的差YYYY-MM-DD hh: mm: ss并以秒或毫秒为单位获取结果?
YYYY-MM-DD hh: mm: ss
SELECT TIMEDIFF('2007-12-31 10:02:00','2007-12-30 12:01:01'); -- result: 22:00:59, the difference in HH:MM:SS format SELECT TIMESTAMPDIFF(SECOND,'2007-12-30 12:01:01','2007-12-31 10:02:00'); -- result: 79259 the difference in seconds
因此,您可以TIMESTAMPDIFF为您的目的使用。
TIMESTAMPDIFF