Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Calculate Age with Gravity Forms

Accurately calculate a customer's age based on their date of birth.

Last updated November 4, 2019 | Written by Scott Buchmann 11 Comments

This article requires the GP Date Time Calculator perk. Buy Gravity Perks today to get this perk plus 33 other premium Gravity Forms plugins!

  • View the Plugin
  • Buy Gravity Perks

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.

Steps

  1. Add a Date of Birth Field
  2. Calculate Age

Step 1 – Add a Date of Birth Field

Add a Date field to your form, call it “Date of Birth”, and set your desired date format.

Date of Birth

Step 2 – Calculate Age

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”.

Age Field

You’re done! Your Number field will automatically display the customer’s age based on the date entered in the Date of Birth field.

The :age merge tag modifier will always return the age in years, regardless of the Date Calculation Unit setting in the Number field.

Steps Beyond

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.

Conditional Logic Settings

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.

Questions? Comments?

Do you have questions or comments about this tutorial? We’d love to hear them!

Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 32+ essential add-ons for Gravity Forms with support you can count on.

  • View All Perks
  • Buy Gravity Perks

Filed Under: How To date field datepicker gp date time calculator

Comments

  1. Prakash says

    November 23, 2020 at 8:53 am

    Calculate age in year and month. currently it is showing year only . we need year and remaining months for the age

    Reply
    • Ryan Donovan says

      November 23, 2020 at 10:21 am

      Hello Prakash, Do you currently have Gravity Forms Date Time Calculator installed? If so, could you please drop us a support request and we could take a closer look at your forms setup? Thank you! ๐Ÿ˜€

  2. Mughees says

    April 2, 2020 at 12:36 am

    Hi i want to caclculate the age in my gravityform. Please let me know how can i find?

    Reply
    • Ryan Donovan says

      April 2, 2020 at 9:45 am

      Hello Mughees, You need to download our Gravity Perks Date Time Calculator. This would require a Gravity Perks license to activate. Once you have that perk, this tutorial will work for you. ๐Ÿ˜€ Let us know if you have any other questions.

  3. Asif says

    March 26, 2020 at 11:09 am

    Hi there, It’s not working. it’s showing the whole date as a number rather years

    Reply
    • Ryan Donovan says

      March 26, 2020 at 12:06 pm

      Hello Asif, Do you currently have Gravity Forms Date Time Calculator installed? If so, could you please drop us a support request and we could take a closer look at your forms setup? Thank you! ๐Ÿ˜€

  4. Michael says

    November 29, 2019 at 8:25 pm

    How would we ensure this number field containing their age is automatically updated as time goes by and they get older? Does Gravity Forms do this by default or do we need to trigger it some how?

    Reply
    • Michael says

      April 13, 2020 at 1:49 am

      Hi. I never did get a response to this question. I certainly would appreciate one!

      Thanks,

      Michael

    • Ryan Donovan says

      April 13, 2020 at 9:04 am

      Hello Michael, Sorry for the delayed response on this one. The field will continue to update based on the input within the date field. Once the item is submitted, the birthday that was submitted will remain as the entry and they will have to resubmit for a new birthday age entry. Let us know if you have any other questions. ๐Ÿ˜€

  5. Faaiza Haque says

    October 28, 2019 at 3:28 am

    How would I go about checking the age on a future date e.g. 11/4/2020 How would I go about doing this? The above method works out the age based on today.

    Thanks

    Reply
    • David Smith says

      October 28, 2019 at 8:01 am

      Hi Faaiza, you can subtract the future date from their birthdate to get the number of years between those dates which would be their age.

      Example: {Future Date:3} - {Birthdate:1}

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories

  • How To (63)
  • News (21)
  • Plugins (14)
  • Releases (7)
  • Resource (3)
  • Snippets (58)
  • Tutorials (57)
  • Updates (104)

Recent Posts

  • How to Update Posts with Gravity Forms
  • Gravity Wiz Weekly #104
  • The Complete Guide to Using Gravity Forms With Zapier
  • Gravity Wiz Weekly #103
  • Show Active Forms by Default on Form List

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2021 ยท Powered by WordPress ยท Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    โ–ผ
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    โ–ผ
    • Documentation
    • Support
    • Account