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

  • Profile Image
    mamoros
    Asked on August 25, 2016 at 10:51 PM
    Calculate age from the Date of Birth date field?
  • Profile Image
    Mike_G
    Answered on August 26, 2016 at 02: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:

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

    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:

    Here's a screenshot of the condition: 

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

    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.