Link to home
Start Free TrialLog in
Avatar of esmyhs
esmyhs

asked on

I need a MySQL Query to find anyone whose Birthday is today

I have a MySql Database with the following fields: First, Last, and DOB. (DOB is a Date Field.)

MySql requires the date to be in the following format: YYYY-MM-DD.

I am wondering if there is a SQL Query where I can return only those whose Birthdays are today, regardless of what year they were born.

Thanks
Avatar of Zyloch
Zyloch
Flag of United States of America image

This is off the top of my head, but maybe something like (where the month and day have to be set based off of the current day):

SELECT date_field FROM your_table WHERE month(date_field) = 1 AND day(date_field) = 5

Open in new window


select ------ from table where date_field = CURDATE();
Avatar of esmyhs
esmyhs

ASKER

Correct me if I'm wrong, but this query won't automatically figure out today's date, will it?
ASKER CERTIFIED SOLUTION
Avatar of Umesh
Umesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of esmyhs

ASKER

theGhost_k8:

The Date in the table is the Date Of Birth. If I understand you correctly, CURDATE() won't find it because the years will be different.
it won't ... mistakes in hurry...
Did you try mine???
Ah yes, the CURDATE() is a nice touch. I need to brush up on my MySQL =)
Avatar of esmyhs

ASKER

You guys are way too quick. Thanks for all the help. This one did it.