Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter records from date in MySQL?

Tags:

sql

mysql

In my database, there is a field called birthday(date) and I want to retrieve records that their birth month and birth day is equal to the current month and the day. Is there a way to write a query for this? Or I just have to do it by retrieving all of the records and find the matching records after by using another program? Thanks!

like image 629
Jayanga Kaushalya Avatar asked Sep 05 '11 15:09

Jayanga Kaushalya


1 Answers

This might also work: (NOTE that I am not sure if you mean day within a Month or day within a week)?

SELECT * FROM TABLE
WHERE MONTH(birthday) = MONTH(CURRENT_DATE)
AND DAY(birthday) = DAY(CURRENT_DATE)    --assuming day within a month
like image 191
VoodooChild Avatar answered Sep 25 '22 02:09

VoodooChild