Your query is going to be hideously inefficient. You're taking a mysql date/time field, converting it to a string, then using that string for comparisons. That precludes any use of indexes.
Why not simply
SELECT ...
...
WHERE (YEAR(timestamp) = 2013) AND (MONTH(timestamp) = 10)
GROUP BY YEAR(timestamp), MONTH(timestamp)
?