Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql Month - Year Comparison

Tags:

mysql

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.

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.

Now I want to do WHERE date >= (January 2013) AND date date <= (December 2014).

Is it possible?

like image 915
Yassi Avatar asked Jan 25 '26 04:01

Yassi


1 Answers

SELECT * FROM TABLE_NAME
WHERE DATE_FORMAT(date, "%Y-%m") BETWEEN '2013-01' AND '2014-12';
like image 181
vikrant singh Avatar answered Jan 26 '26 17:01

vikrant singh