Reputation: 325
I need a code that checks Joomla MySQL database and depending on the year and depending on the month pulls data from there. I can extract a single quote, but cannot find the way to extract data only by year and/or only by month.
$query->where($db->quoteName('receive_date') . ' = '. $db->quote('2012-11-08 17:47:00'));
What is the solution?
Thanks
Upvotes: 0
Views: 455
Reputation: 1021
Using the mysql YEAR() function on a date column will return the YEAR.
Using MONTH() on a date column will return the MONTH.
This example (untested but should work) should put you on the right track:
$query->where('YEAR('.$db->quoteName('receive_date').') = '. $db->quote('2012'));
Upvotes: 1