Rapu Ture - Exploring the Rules

The age of a Person (in years)

Int DAY Person Formula Included used 23 times

Value type Int . Default value -9999 Entity person

How is this calculated?

To calculate this variable, the following input is used

Where is this used?

This variable is referred to by these other variables in their own calculations


This is the formula used to calculate the value of age


This formula is used for scenarios from the date 0001-01-01 onwards. More info on formulas

def formula(persons, period, parameters):
    birth = persons('date_of_birth', period)
    birth_year = birth.astype('datetime64[Y]').astype(int) + 1970
    birth_month = birth.astype('datetime64[M]').astype(int) % 12 + 1
    birth_day = (birth - birth.astype('datetime64[M]') + 1).astype(int)

    is_birthday_past = (birth_month < period.start.month) + (birth_month == period.start.month) * (birth_day <= period.start.day)
    return (period.start.year - birth_year) - where(is_birthday_past, 0, 1)  # If the birthday is not passed this year, substract one year