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!

Help with calculating birthday's

Status
Not open for further replies.

BCarruth

Programmer
Feb 8, 2001
19
US
Is there a way to create a query that will show everyone who has a birthday either today or in a week?
 
oft discussed and answered. use the search thinggy with 'birthdaty and / or birthdate. Basically usaes date serial to replace DOB year w/ current year, then see if difference is within interval (day/week/month).

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
BCarruth
This is one of the FAQs that I think will help you!
Select birthdays within the next 30 days ...
faq181-1374

As usual, there is more than ine way to skin a cat ... this select statement can be pasted straight into QBE sql but do not forget to change table (Employees) and field name (Birthdate) ...

SELECT Employees.Birthdate,

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

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

(Int((Now()-[birthdate])/365.25)+1) AS AgeNextBirthday, [Age]+1 AS Next

FROM Employees

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

NOTE : the WHERE statement is exactly the same as the NextBirthday line.

Good Luck!
RookieDev
 
If I wanted to expand on this to show dates spans of +30 and -30 how would I do that.

Changing

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

to

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

shows no difference in the results.

Thans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top