Mysql 按時間查詢的幾個函數使用方法

查詢昨天的數據    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());

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章