针对 NOW
或者CURRENT_TIMESTAMP
或者SYSDATE
类型
`update_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT 'update time'
- 24小时
SELECT xxx
FROM xxxtable
WHERE DATE_FORMAT(update_time,'%Y%m%d%H')>=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 24 HOUR),'%Y%m%d%H')
ORDER BY update_time DESC
- 7天前
SELECT xxx
FROM xxxtable
WHERE
DATE_FORMAT(update_time,'%Y%m%d')>=DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL 7 DAY),'%Y%m%d')
ORDER BY update_time DESC
网友评论