test age range with iif function

pb21

Registered User.
Local time
Today, 15:50
Joined
Nov 2, 2004
Messages
122
I would like to have an iif function determine the age range of the person. I have in the query grid the dob and a column called age range and would like the following.



age range: IIf(DateDiff("yyyy",[Date of Birth],Now())+Int(Format(Now(),"mmdd")<Format([Date of Birth],"mmdd"))>=11 and <=15,"11 to 15","next age range formula here")

obviously the above does not work due to the And logic. how do I implement that in the query grid function?

regards in advance

Peter
 
What are you trying to determine with your calculation? Simply the age of the person based on their DOB? And then place that person in an age range category?

For this purpose a function would probably serve you better than a cluster of nested IIf's.
 
age range

yes that is exactly what i want to do, should i place a public function in a module and then pass dob to the grid?

i guess

select case input

case >=11 and <=15

code here

case >=16 and <= 17

case >=18


end select

some code to return variable

regards
 
Yes, if you pass the DOB as a function argument you can use this simple formula to calculate the person's age and then work out your age brackets from there using Select Case.


Age = Int((Date()-[DOB])/365.25)
 

Users who are viewing this thread

Back
Top Bottom