Scorptique Posted December 6, 2008 Share Posted December 6, 2008 Ive been researching for hours but I cant seem to find the solution. How do I display the upcoming birthdays from my database? my table is called contact_list and amongst the other attributes stored, it stores the cl_id's Date of Birth (cl_dob). I tried datediff but that will only show me the oldest person to the youngest, not the upcoming birthdays. Can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/ Share on other sites More sharing options...
fenway Posted December 8, 2008 Share Posted December 8, 2008 I'm sure this has been covered at least a handful of times on this forum... search "harder"... it's buried here somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/#findComment-708929 Share on other sites More sharing options...
Scorptique Posted December 8, 2008 Author Share Posted December 8, 2008 I can't find it. Most of the search results return upcoming EVENTS. DOB and events are different because the year for upcoming even is > 2008 however the year for DOB is < 2008. I tried like 20 over statements but they all fail. Someone please help me. This one doesnt work either: Select cl_id, cl_fname, cl_lname, cl_email, date_format(cl_dob, '%d %b %Y') AS cl_dob, (DAYOFYEAR(NOW() +INTERVAL 365 day) - DAYOFYEAR(cl_dob)) AS diff from contact_list where username='$username' HAVING diff BETWEEN 1 AND 365 Neither does this one: select cl_id, cl_fname, cl_lname, cl_email, date_format(cl_dob, '%d %b %Y') AS cl_dob, period_diff(date_format(now(), '%m'), date_format(cl_dob, '%m')) as datesDiff from contact_list where username = '$username' order by datesDiff desc, day(cl_dob) I cleared the rest >< Quote Link to comment https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/#findComment-709137 Share on other sites More sharing options...
fenway Posted December 8, 2008 Share Posted December 8, 2008 How about this thread? Quote Link to comment https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/#findComment-709510 Share on other sites More sharing options...
prcollin Posted December 9, 2008 Share Posted December 9, 2008 why not just do just do something like select from blah where cl_dob is between todays date and today + 7days. I dont know how to do it myself but it shouldnt be that hard to create a simple function like that then just echo all the results Quote Link to comment https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/#findComment-710717 Share on other sites More sharing options...
fenway Posted December 9, 2008 Share Posted December 9, 2008 why not just do just do something like select from blah where cl_dob is between todays date and today + 7days. I dont know how to do it myself but it shouldnt be that hard to create a simple function like that then just echo all the results You still have to deal with the year issue... hence the previous thread. Quote Link to comment https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/#findComment-710747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.