Jump to content

Displaying upcoming birthdays


Scorptique

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/135824-displaying-upcoming-birthdays/
Share on other sites

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 ><

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.