Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
in my table i stored birth dates of customer and i want to get upcomin 5 bdays
using stored procedure i uses smalldatetime datatype for storing date
Help me
Thank u
Posted

A birthday is on the same date every year so you actually only have problem if one celebrates ones birthday on February the 29th because of being born in a leap year. Determining if a year is a leap year is simple and can easily be googled.

Regards,

Manfred
 
Share this answer
 
Comments
Wendelius 8-Jan-12 6:27am    
True, my 5.
I wouldn't store the upcoming birthdays. Just store the actual birthday and then you can calculate (or actually fetch as Manfred described) the upcoming birthdays.

Also note that depending on your local laws and regulations, storing birthdays may be a subject to a permission and/or a notification to authorities.
 
Share this answer
 
i found solution for upcoming Bdays

SQL
SELECT  bDate  AS
Birthday  ,FLOOR(DATEDIFF(dd,bDate,GETDATE()) / 365.25) AS
 Age_Now  ,FLOOR(DATEDIFF(dd,bDate,GETDATE()+180) / 365.25) AS
 Age_After_this_Week
 FROM   CustomerMaster WHERE 1 = (FLOOR(DATEDIFF(dd,bDate,GETDATE()+180) / 365.25))
    -           (FLOOR(DATEDIFF(dd,bDate,GETDATE()) / 365.25))


Note- 180 for get bdays from upcoming 6 months

thanks for support
 
Share this answer
 
Comments
member60 8-Jan-12 6:46am    
my 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900