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.

1 Answer 1


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)

  • That would calculate the age acording to today date, but i really need it to calculate the age on january the 1st. Dec 23, 2017 at 0:51
  • Late to the party on this one, but having stumbled onto this thread will looking for how to calculate age on a specific date, we just need to modify Nicholas' answer a bit to =DateTime.Parse("31/7/2020").Year - BirthDate.Year + (if DateTime.Parse("31/7/2020").Month < BirthDate.Month or (DateTime.Parse("31/7/2020").Month = BirthDate.Month and DateTime.Parse("31/7/2020").Day < BirthDate.Day) then -1 else 0) or to remove the hardcoded year =DateTime.Today.Year - DateOfBirth.Year + (7 < DateOfBirth.Month or (7 = DateOfBirth.Month and 31 < DateOfBirth.Day) ? -1 : 0) Feb 12, 2020 at 13:52

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.