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