Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Trying to Find Who's Birthday
July 13, 2004, 7:53 pm
rate this thread
and the day, the year doesn't matter). I am trying to have a query that
returns the names of those whose birthdays are today. Currently I am
returning everyones birthdays and then looping through them doing a
string comparison. Can't I do this work in the query?
$bday_qry="SELECT user_fname, user_lname, user_bday
WHERE DATE_FORMAT(user_bday, %m-%d)==".date("m-d");
What's the best way to do this?
Re: Trying to Find Who's Birthday
Sure, you can simple select the birthdays for the current day in the WHERE
$current_date = getdate(); //www.php.net/getdate for reference
$bday_qry = "SELECT ";
$bday_qry.= "user_fname, user_lname, DATE_FORMAT(user_bday, '%m-%d') AS bday
$bday_qry.= "WHERE "
$bday_qry.= "MONTH(user_bday) = '" . $current_date['mon'] . "' AND
DAYOFMONTH(user_bday) = '" . $current_date['mday'] . "' AND YEAR(user_bday)
= '" . $current_date['year'] . "'";
That should do it I think =D.
Sharif T. Karim
....you don't know wrath yet...