mysql几个时间函数

-- 取得相隔秒数
SELECT UNIX_TIMESTAMP('2012-06-09 00:10:11')-UNIX_TIMESTAMP('2012-06-09 00:09:12')


-- 取得相隔分钟数
SELECT round((UNIX_TIMESTAMP('2012-06-09 00:10:11')-UNIX_TIMESTAMP('2012-06-09 00:09:12'))/60)
 
时间函数:
SELECT NOW();


SELECT CURRENT_DATE();


SELECT CURRENT_TIMESTAMP()


SELECT DATE_SUB(NOW(),INTERVAL 1 HOUR)


SELECT DATE_SUB(NOW(),INTERVAL 1 DAY)


SELECT DATEDIFF('2012-11-28','2012-11-25')


SELECT DATE_FORMAT(NOW(),'%m/%d/%Y %H:%i:%s')

你可能感兴趣的:(mysql)