For complete dates:
-- Se seu campo for DATE:
SELECT * FROM tabela WHERE DATE(minhadata) = '2014-05-21';
-- Se seu campo for VARCHAR:
SELECT * FROM tabela WHERE LEFT(minhadata,10) = '2014/05/21';
For year only:
-- Se o campo for DATE:
SELECT * FROM tabela WHERE YEAR(minhadata) = '2014';
-- Se o campo for VARCHAR:
SELECT * FROM tabela WHERE LEFT(minhadata,4) = '2014';
For month only:
-- Se o campo for DATE:
SELECT * FROM tabela WHERE MONTH(minhadata) = '05';
-- Se o campo for VARCHAR:
SELECT * FROM tabela WHERE SUBSTR(minhadata, 6, 2) = '05';
For day only: :
-- Se o campo for DATE:
SELECT * FROM tabela WHERE DAY(minhadata) = '23';
-- Se o campo for VARCHAR:
SELECT * FROM tabela WHERE SUBSTR(minhadata, 9, 2) = '23';
Combining the above possibilities
Here's an example of how to get the records for the 17th of every month in 2013:
-- Se o campo for DATE:
SELECT * FROM tabela WHERE
YEAR(minhadata) = '2013' AND
DAY(minhadata) = '17';
-- Se o campo for VARCHAR:
SELECT * FROM tabela WHERE
LEFT(minhadata,4) = '2013' AND
SUBSTR(minhadata, 9, 2) = '17';
Notice that I'm considering the date VARCHAR
in the format AAAA/MM/DD
.
For other formats, set SUBSTR(campo,posicaoinicial,quantidade)
accordingly.