3 Replies Latest reply on Jun 5, 2014 3:04 PM by philmodjunk

# Current Age Group Calculation Field

### Title

Current Age Group Calculation Field

### Post

I have a popup field of four (4) age groups. I want to be able to calculate the person's current age and then have the AgeGroup field automatically choose the appropriate age group.

I know the calculation for the current age will be: CurrentDate - Birthdate (field)

And I have a vague understanding of calculating the AgeGroup field once you get the current age:

Case (<5; Peewee;

<9; Child;

<13; Junior;

But I can't wrap my head around putting all the pieces together. Will I have to make a field for the CurrentAge calculation, or will that calc just be included in the AgeGroup calculation? Do I need to make a separate AgeGroup table to make a value list for the AgeGroup field? And will the AgeGroup field always be up-to-date as the current date changes?

• ###### 1. Re: Current Age Group Calculation Field

CurrentDate - Birthdate

will calculate the person's age, but in days, not years.

Let (  [ B = YourTable::BirthDateField ;
T = Get ( CurrentDate )
] ;
Year ( T ) - Year ( B ) - ( T < Date ( Month ( B ) ; Day ( B ) ; Year ( T ) ) )
)

will calculate an age in years. Assuming that you put the above as the definition for an unstored calculation field named Age, your Case Function will look like:

Case ( Age < 5 ; "Peewee" ;
Age < 9 ;  "Child" ;
Age < 13 ; "Junior" ;