Need to Create formula that calculates someones age from DOB-READ!

G

Guest

Help

I have created a database that gathers various information about a person
including their childrens names and date of birth. I also have I have a
field name called ChildStatus which needs to show whether the child is an
adult, teenager or younger. I would like to create a formula in this
ChildStatus field that does the following:
Looks at the date of birth field
Determines the current age
If that age is 18 or older the output in the ChildStatus field should be Adult
If that age is 13-17 the output in the ChildStatus field should be Teen
If that age is 12 or younger the output in the ChildStatus field should be
Child
 
D

Douglas J. Steele

You cannot have a field in a table calculate its value from the value of
other fields in the table, nor should you.

There's no need to store that ChildStatus value in the table. Instead, add
it as a computed field in a query, and use the query wherever you would
otherwise have used the table.

To do your calculation, you could use something like:

ChildStatus: IIf(DateAdd("yyyy", 18, [DoB]) <= Date(), "Adult",
IIf(DateAdd("yyyy", 12, [DoB]) <= Date(), "Teen", "Child"))

For the record, to calculate the current age given today's date, use
something like:

Age: DateDiff("yyyy", [DoB], Date()) - IIf(Format(Date(), "mmdd") <
Format( [DoB], "mmdd"), 1, 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top