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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.