Mysql月-年比较 [英] Mysql Month - Year Comparison
本文介绍了Mysql月-年比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我只想问一下如何以仅月份-年份"为条件的查询?例如,范围是2013年1月-2014年12月?
Hi guys I just want to ask how can I make a query that conditions a Month - Year only selection? Like, Where the range is January 2013 - December 2014?
我的表格中有一个日期"列.
i have a "date" column in my table.
我通常会使用"WHERE date> =?AND date< =?"之类的日期范围至今为止.我只想选择月"和年",而不选择天".
I usually do a date range like "WHERE date >= ? AND date <= ?" which is from date to date. I only want to select the Month and Year only, without the day.
现在,我要执行日期> =(2013年1月)且日期日期< =(2014年12月). 是否有可能?感谢您的帮助!
Now I want to do "WHERE date >= (January 2013) AND date date <= (December 2014). Is it possible? Thanks for the help!
推荐答案
SELECT * FROM TABLE_NAME
WHERE DATE_FORMAT(date, "%Y-%m") BETWEEN '2013-01' AND '2014-12';
这篇关于Mysql月-年比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文