mysql 按年月查詢


查詢2017的數據:select * from table where year(column)='2017';
查找月份為12的數據:select * from table where month(column)='12';
查找天數為本年第二天的數據:select * from table where dayofyear(column)='2';

year,month,dayofyear是mysql的函數,分別是取得年,月,和當前時間在本年是第幾天的3個函數

查詢當月數據:select * from table
where date_format(column,'%Y-%m')=date_format(now(),'%Y-%m')
 
         
         
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM