You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND calendar_date BETWEEN '2014-11-01' AND '2015-01-31' Order By calendar_date' at line 1