James Simpson James Simpson - 1 year ago 72
SQL Question

Use MySQL to determine whether today is a user's birthday

I have all users' birthdays stored as a UNIXtimestamp and am wanting to send out e-mails each day to users that have a birthday that day.

I need to make a MySQL query that will get all of the rows that contain a birthday on today's date.

It seems like this should be fairly simple, but maybe I am just overcomplicating it.

Answer Source

This should work:

   SELECT * 
         DATE_FORMAT(FROM_UNIXTIME(birthDate),'%m-%d') = DATE_FORMAT(NOW(),'%m-%d')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download