Cognito-forms – Age at January 1st in Cognito Forms

cognito-forms

I would like to know what formula to use in age calculation to get someone’s age at January the 1st 2018, after input of his date of birthday.

Best Answer

I'm a developer with Cognito Forms.

We do have an age calculation in our help content that can be set up to display a users age based on their entered birthday.

  1. Add a Date field to your form labelled Birth Date.

  2. Add a Calculation field labelled Age, set to the Text type.

  3. Insert the following expression as your calculation:

=DateTime.Today.Year - BirthDate.Year + (if DateTime.Today.Month < BirthDate.Month or (DateTime.Today.Month = BirthDate.Month and DateTime.Today.Day < BirthDate.Day) then -1 else 0)