Reputation: 20
I am saving the reporting date as date format (ex 2017-04-05) now I want the records only between two years based on reporting date, I am giving the from year and two year as 2016 and 2017
The above table is my table structure
Now I want to get the records where report_date between year 2016 and 2017, I will not give complete date only I will give the year.
Upvotes: 0
Views: 1267
Reputation: 1222
You can use YEAR() to get just the year of a date, then you can search between years like so:
SELECT *
FROM reports
WHERE YEAR(report_date) BETWEEN 2015 AND 2016;
Upvotes: 3