As of now, Easy Forms has a special feature that would let you calculate the age using the date of birth quickly.
To get started, we are going to create a Form with a Date field (Label: Date of Birth), a Number field (Age), and a Submit button. Your form should look like this screenshot:
Now go to the Rule Builder (Forms > Actions > Conditional rules) and click “Add rule”.
1. Name: Calculate Age From Date Of Birth
2. Click “Add condition” > Date of Birth is present
3. Click “Add action” > Evaluate
5. Formula: differenceInYears(now(), {{date_1}})
6. Set Result to Field: Age.
Your Rule should look like this screenshot:
Note: The differenceInYears()
function calculates the number of years between two dates. Then we use the now()
function to obtain the first date and the second date is obtained from the Date field.
That’s all!
Now your form should look like this: