View Single Post
  #5 (permalink)  
Old 03-12-2008, 09:13 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: mysql php - help needed

This should work, I believe:

SELECT * FROM table WHERE MONTH(date_of_birth) = MONTH(CURDATE()) AND DAY(date_of_birth) = DAY(CURDATE()) AND email NOT NULL AND email !='';

Edit for less processing overhead:

SELECT * FROM table WHERE DATEFORMAT(date_of_birth, '%c %e') = DATEFORMAT(CURDATE(), '%c %e') AND email NOT NULL AND email !='';

You could go even easier, if there is a large database, and replace the second DATEFORMAT() with a PHP variable containing the current date and month, separated by a space.
__________________
The best way to learn anything, is to question everything.

Last edited by wige : 03-12-2008 at 09:18 AM.
Reply With Quote