954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Show upcoming 7 birthday

Hi,

I want to show users upcoming 7 birthday.

Here is my user table

user_birth_date user_id
1984-08-09 1
2000-08-22 5
2000-07-23 8
1985-08-24 11
1986-08-25 28
2002-08-19 27
1982-08-26 26
1987-08-05 24
0185-09-27 25
1985-09-02 29
1987-08-31 30
1980-03-22 31
1982-10-20 33

i use query

$sql_bday="SELECT CONCAT(YEAR(CURRENT_DATE()),'-',date_format( user_birth_date, '%d-%m' )  ) AS new_bdate,user_id from pm_user;


Please tell me some idea to display upcoming 7 birthday?

Aamit
Posting Whiz
342 posts since Apr 2008
Reputation Points: 3
Solved Threads: 15
 

Use the DATE_ADD() function to determine the seventh birthday:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add

Then combine it with the DATE_FORMAT() to format the output:

SELECT DATE_FORMAT(DATE_ADD(`user_birth_date`, INTERVAL 7 YEARS), '%m/%d/%Y') as seventhBDay

hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You