3

Which is the right formula to calculate the age in a form used for candidates selection?

In the example, they have to insert their DOB and in another space I would like to have the result of their age. I have tried different formulas, like the difference between DOB and today date, but without success.

1 Answer 1

1

I am a developer for Cognito Forms

You can do this with the use of two fields. The first field is a Date filed with the label of "Birth Date". This will be the title I use in the calculation in our next field.

The next field we need to add is a Calculation field. You can title this anything you need to and for this example I used "Age" we are then going to use the fallowing calculation in the calculation field.

=DateTime.Today.Year - BirthDate.Year + (DateTime.Today.Month < BirthDate.Month or (DateTime.Today.Month = BirthDate.Month and DateTime.Today.Day < BirthDate.Day) ? -1 : 0)

This will allow a user to input their birth date into the Date field and the users age will be placed as a number onto the form in the Age field.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.