Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Birthday query

Status
Not open for further replies.

Buffmeat

Programmer
Dec 19, 2001
2
US
We have an Access database with all our employees in it. On our Intranet they want me to display everyone that is going to have a birthday in the next 30 days. I am having trouble ignoring the year field in the birthdate to determine this. Does anyone know what I need to do to ignore year and still get the results I need?

Thanks in advance
 
try this one which i have used in the past ... it will give you person's date of birth, age, date of next birthday and age next birthday ... you can edit as required of course ...

SELECT Employees.Birthdate,

Int((Now()-[birthdate])/365.25) AS Age,

[Birthdate]+((Int((Now()-[birthdate])/365.25)+1)*365.25) AS NextBirthday,

[Age]+1 AS AgeNextBirthday

FROM Employees

WHERE ((([Birthdate]+((Int((Now()-[birthdate])/365.25)+1)*365.25)) Between Now() And Now()+30));

good luck ... Best of Irish Luck, David.
djwilkes@hotmail.com
 
This works great!!! Except for one minor problem. I can't see today's birthdays. I have tried to modify the string but I didn't know if you could offer any suggestions.

Thanks a lot though. I'm a lot better off than I was...
 

A couple of suggestions.

1) Use Date() rather than Now(). Now() includes the time as well as the date.

2) To find birthdays in the current (or next) month, use the Month() function.

Current month:
Select Name, DOB
From Table
Where Month([DOB])=Month(Date())

Next month:
Select Name, DOB
From Table
Where Month([DOB])=Month(Dateadd("m", 1, Date()))
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top