lional Posted March 20, 2009 Share Posted March 20, 2009 I have two fields in a database table one for day of birth and one for month of birth. I would like to pull whose birthday it is today, but if the birthday falls on a monday I would like to include the previous 2 days in the query. The day of birth is saved in numerical form 1 - 31, and the month is January - December. I am not interested in the year. I am not sure how to pull this info from the database Thanks in advance Lional Link to comment https://forums.phpfreaks.com/topic/150288-pulling-birthdays-from-mysql/ Share on other sites More sharing options...
suma237 Posted March 20, 2009 Share Posted March 20, 2009 $today = date("F m Y"); $explode_date = explode(" ",$today); echo "Month:".$explode_date[0]; echo "<br>Date:".$explode_date[1]; [code] compare the array value with the mysql data Link to comment https://forums.phpfreaks.com/topic/150288-pulling-birthdays-from-mysql/#findComment-789297 Share on other sites More sharing options...
lional Posted March 20, 2009 Author Share Posted March 20, 2009 will this let me pull 2 days back if the birthday falls on a monday Link to comment https://forums.phpfreaks.com/topic/150288-pulling-birthdays-from-mysql/#findComment-789316 Share on other sites More sharing options...
redarrow Posted March 20, 2009 Share Posted March 20, 2009 | SELECT * FROM `friends` WHERE ( | EXTRACT(MONTH FROM `birthday` ) = EXTRACT(MONTH FROM | CURDATE()) | AND | DAYOFMONTH(`birthday`) >= DAYOFMONTH(CURDATE()) | AND | DAYOFMONTH(`birthday`) <= (DAYOFMONTH(CURDATE()) + 15) | ) | | OR ( | EXTRACT(MONTH FROM `birthday`) = EXTRACT(MONTH FROM | ADDDATE(CURDATE(), INTERVAL 15 DAY)) | AND | DAYOFMONTH(`birthday`) <= DAYOFMONTH(ADDDATE(CURDATE(), | INTERVAL 15 DAY)) | ) url bottom page read please. http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Link to comment https://forums.phpfreaks.com/topic/150288-pulling-birthdays-from-mysql/#findComment-789324 Share on other sites More sharing options...
suma237 Posted March 20, 2009 Share Posted March 20, 2009 $day1=date(l);//display day if($day1=='Monday') { $sql=mysql_query("SELECT SUBDATE('2009-03-20', INTERVAL 2 DAY)"); ........continue coding } [code] Link to comment https://forums.phpfreaks.com/topic/150288-pulling-birthdays-from-mysql/#findComment-789332 Share on other sites More sharing options...
lional Posted April 1, 2009 Author Share Posted April 1, 2009 I am a bit confused with the SUBDATE. I have a field in the mysql table called display_date of type varchar, and it is stored in the format of yyyy-mm-dd. On your code above where am I referencing that it is from this field that I would like to compare the dates. Thanks Lional Link to comment https://forums.phpfreaks.com/topic/150288-pulling-birthdays-from-mysql/#findComment-798644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.