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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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)
 
Back
Top