I am storing records with a date value in the format: yyyy-mm-dd (2017-03-25).
I want to now SELECT all records in the month that it is at the time of viewing the page. So, if I view today, it should show me all records for March 2017. If I view in April, then it should show me all records for April 2017and not April for every year i.e. 2016, 2015, 2014 etc.
In my SELECT statement I don't know if that is where I should try to strip out the day and just extract the month and year or if that would have to be done elsewhere.
I can get the current month and year like:
$current_month = date("m");
$current_year = date("Y");
But then I am not sure how to handle the SQL. I tried something like this but no joy.
SELECT `lost`, EXTRACT (YEAR FROM `summary`) AS currentyear WHERE currentyear = ?