How to calculate age from the Date of Birth date field?

  • mamoros
    Asked on August 25, 2016 at 10:51 PM
    Calculate age from the Date of Birth date field?
  • Mike_G JotForm Support
    Replied on August 26, 2016 at 2:37 AM

    To calculate the age, you will be needing two date fields. One date field is where the date of birth is going to be entered and the other one is the one that will hold the current date or date today. You will also be needing a textbox field to display the output(age).

    First, add the fields:

    How to calculate age from the Date of Birth date field? Image 1 Screenshot 60

    Then, set a default date(current) for the "Current Date" date field. You should also set the field to hidden.

    How to calculate age from the Date of Birth date field? Image 2 Screenshot 71

    After that, create a condition that says, "If the 'Date of Birth' date field is filled, calculate the age". 

    To calculate the Age, subtract the "Date of Birth" date field value from "Current Date" date field value. The difference will be in days, so you need to divide the value by 365.25 days to get the year(s). 

    You also need to get the value rounded down, that is why you will use the "floor()" math function. You need to do that so birthdays in November will not be counted as 1 if it's only August, for example.

    Here's how it is done:

    How to calculate age from the Date of Birth date field? Image 3 Screenshot 82

    Here's a screenshot of the condition: 

    How to calculate age from the Date of Birth date field? Image 4 Screenshot 93

    I would also suggest you disable future dates for the "Date of Birth" date field.

    How to calculate age from the Date of Birth date field? Image 5 Screenshot 104

    Here's a sample form: https://form.jotform.com/62380981430960

     

    I hope this helps. If you need any further assistance, please contact us anytime. Thank you.