MySQL计算时间差

SELECT NOW() - '2012-11-11 00:00:00' AS c;
SELECT NOW();
SELECT DATEDIFF(DAY, '2012-11-11 00:00:00' ,NOW());
SELECT DATEDIFF(NOW(), '2012-11-11 00:00:00');
SELECT DATEDIFF(NOW(), '2014-11-11 11:00:12');
SELECT TIMEDIFF(NOW(), '2014-10-21 00:00:00');
SELECT TO_DAYS('2014-10-21 00:00:00');
SELECT DATEDIFF(NOW(), '2014-05-09 00:00:00');
SELECT DATEDIFF(NOW(), '2014-10-20 23:59:59');
SELECT NOW();
SELECT 
SELECT TO_DAYS(NOW()) - TO_DAYS('2012-10-10 00:00:00');

SELECT TIME_TO_SEC(NOW()) - TIME_TO_SEC("2012-10-10 00:00:00");

SELECT TIME_TO_SEC("2012-10-10 00:00:00");
SELECT TIME_TO_SEC(NOW());

SELECT TIME_TO_SEC(DATEDIFF(NOW(), '2012-10-10 00:00:00'));

SELECT DATEDIFF(NOW(), '2012-10-10 00:00:00')

SELECT TIME_TO_SEC(NOW())
SELECT TIME_TO_SEC('2012-10-10 00:00:00');

SELECT TIMESTAMPDIFF(HOUR, '2014-10-21 00:00:00', NOW()) < 72;

SELECT TIMESTAMPDIFF(YEAR, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(QUARTER, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(MONTH, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(WEEK, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(DAY, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(HOUR, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(MINUTE, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(SECOND, '2014-10-21 00:00:00', NOW());
SELECT TIMESTAMPDIFF(MICROSECOND, '2014-10-21 00:00:00', NOW());

你可能感兴趣的:(mysql)