码迷,mamicode.com
首页 > 数据库 > 详细

mysql 按年月查询

时间:2017-08-18 11:50:31      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:text   select   函数   style   pre   from   mysq   查询   for   

查询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‘)

mysql 按年月查询

标签:text   select   函数   style   pre   from   mysq   查询   for   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!