Search all records of a respective year and month

2

In my DB I have the date field of type date (YYYY-mm-dd). What happens is that I want to fetch all records for a given year and month. For example, I want to go fetch all the records for 2014 from month 08. How can I do this? I tried something like this:

SELECT * FROM tbl_ocorrencias WHERE 'data' = '2014-08-d' 
    
asked by anonymous 29.08.2014 / 18:08

1 answer

6
SELECT * FROM tbl_ocorrencias
WHERE
   YEAR( data ) = 2014 AND MONTH( data ) = 8
    
29.08.2014 / 18:12