Search all records for a respective year and month

Asked

Viewed 64 times

2

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

SELECT * FROM tbl_ocorrencias WHERE `data` = '2014-08-d' 

1 answer

6


SELECT * FROM tbl_ocorrencias
WHERE
   YEAR( data ) = 2014 AND MONTH( data ) = 8

Browser other questions tagged

You are not signed in. Login or sign up in order to post.