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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with converting D_O_B into an age

Status
Not open for further replies.

shughes1984

Technical User
Joined
Feb 13, 2003
Messages
1
Location
GB
Hi
I am having a problem with Access.
I have used the following DatDiff formula to work out age from my D_O_B field-
=DateDiff("y",[D_O_B],Now())/365

this worked within a form, but when i want to use a parameter query to list all members of a certain age, it doesn't work.
I need to be able to enter an age into the parameter query so that it will show all members of this age.
obviously because this information is coming from a form, it isn't proving easy to use it within a query.
Please try to help
 
In your query, list this as the criteria for [D_O_B]
Round(DateDiff("y",[D_O_B],Now())/365)=[AgeGiven]
When opened, the query will prompt the user to enter an age
The Round was there presuming that your users are entering whole years, not 20.345959
If you need a range of ages, try
(DateDiff(&quot;y&quot;,[D_O_B],Now())/365)>=([YoungestAge]) And (DateDiff(&quot;y&quot;,[D_O_B],Now())/365)<=([OldestAge]) for two prompts for the youngest and oldest dates.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top