首页 > 数据库技术 > 详细

mysql 按年月查询

时间:2017-08-18 11:47:24      阅读:383      评论:0      收藏:0      [点我收藏+]
查询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 按年月查询

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!