查詢昨天的數據 select * from faq where answer_time = date_sub(curdate(),interval 1 day);
查詢本月的數據 select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m');
查詢今天的數據 select * from faq where date_format(answer_time,'%y-%m-%d') = date_format(now(),'%y-%m-%d');
查詢當前這周的數據 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now());
作者“csupanpan的專欄”