0

Calculating Age in Cognito Forms.

Age in years:

= 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)

This way we can calculate the age today, what about if I need to calculate the age, in years, at January the 1st 2019?

0

The easiest way for you to this is to simply replace

DateTime.Today

with

DateTime.Parse("1/1/2019")

This calculation would also work, and is less complicated.

=DateTime.Parse("1/1/2019").AddTicks(-BirthDate.Ticks).Year - 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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