mysql 按年月查询

时间:2017-08-18 11:47:24   收藏:0   阅读:383
查询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‘)

原文:http://www.cnblogs.com/-xuzhankun/p/7388755.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!