Calculate Age with Gravity Forms
This article requires the GP Date Time Calculator perk.
Buy Gravity Perks to get this perk plus 47 other premium Gravity Forms plugins!
One of the most common fields we see on forms is a date of birth field. With the user’s date of birth you are able to calculate their age and with their age you can implement a variety of powerful interactions.
- Restrict registration to users above a certain age.
- Provide lower product pricing to children and seniors (see our Aged-based Pricing article).
- Send promotional emails to customers on their birthday, personalized to their specific age.
In this tutorial, you’ll learn how easy it is to calculate a customer’s age from their date of birth using Gravity Forms Date Time Calculator.
Add a Date field to your form, call it “Date of Birth”, and set your desired date format.
Add a Number field to the form and name it “Age”. In the Formula box, insert the merge tag for the Date of Birth field
and add the
:age merge tag modifier to it. In this example, my Date of Birth field ID is “1”.
You’re done! Your Number field will automatically display the customer’s age based on the date entered in the Date of Birth field.
:age merge tag modifier will always return the age in years, regardless of the Date Calculation Unit setting in
the Number field.
Once you have set up the fields to calculate your customer’s age, the possibilities are endless. Use age with conditional logic, for example to hide the submit button unless the customer is above or below a certain age.
You can also set up pricing or discounts based on their age. For example, to offer senior discounts. Follow the steps in our How to Set Up Age Based Pricing to learn more.
Do you have questions or comments about this tutorial? We’d love to hear them!