-- 当前日期 select DATE_FORMAT(NOW(),'%Y%m%d') from dual; -- 前三十天 select DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 30 DAY),'%Y%m%d') from dual; -- 前7天 select DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 7 DAY),'%Y%m%d') from dual; -- 上个月 select DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH),'%Y%m%d') from dual; -- 本月 select DATE_FORMAT(CURDATE(),'%Y%m01') from dual; select DATE_FORMAT(LAST_DAY(CURDATE()),'%Y%m%d') from dual; -- 本周 select DATE_FORMAT(SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-1), '%Y%m%d') from dual; select DATE_FORMAT(SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-7), '%Y%m%d') from dual; -- 前天 select DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 DAY),'%Y%m%d') from dual; -- 昨天 select DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 DAY),'%Y%m%d') from dual;