查询2011的数据:select * from 表 where year(date)='2011';
查找月份为12的数据:select * from 表 where month(date)='12';
查找天数为本年第二天的数据:select * from 表 where dayofyear(date)='2';
我解释一下:
select * from 表 where 这是必须的
year,month,dayofyear是mysql的函数,分别是取得年,月,和当前时间在本年是第几天的3个函数
date就是你保存时间的字段
转载于:https://my.oschina.net/zhangb081511/blog/178758