Calculate Age based on birth date

  • Profile Image
    hatzbs
    Asked on November 11, 2015 at 11:39 AM

    I would like to calculate age. For instance, I have a Date of Birth field, and an age field. I would like to automatically calculate the age of the person based on the Date of Birth. I attempted to use the calculate field, but I am sadly lost. :(

     

    Assistance would be greatly appreciated. 

  • Profile Image
    Charlie
    Answered on November 11, 2015 at 01:39 PM

    I'm unable to understand properly the form you have. But you can try this sample form that I made: https://form.jotform.com/53144880775968?. To calculate the age based from the date of birth, here are the steps:

    1. First, have two Datetime field. The 1st one will get the current date while the other is for the date of birth.

    2. Add a form calculation widget as the age field. We will do the calculation there.

    3. In my form calculation widget, this is the formula I have.

    floor((current date - date of birth)  / 365 days)

    floor - this will round your number value downward. You can check this link for the reference: http://www.jotform.com/help/267-Form-Calculation-Math-Function-Reference 

     

    Let us know if that works.

  • Profile Image
    hatzbs
    Answered on November 11, 2015 at 03:23 PM

    I am getting this in the age field after the calculation is made:

     

    today - year =

  • Profile Image
    hatzbs
    Answered on November 11, 2015 at 03:45 PM
    Yuch. This is what I get in the age field when I try to run the calculation:
    today - year =
    ...
  • Profile Image
    EltonCris
    Answered on November 11, 2015 at 04:52 PM

    It is because of your update a field value condition with just "today - year =" text in the formula. I have now updated it for you. Check the age calculation in your form now. It should now be working.

  • Profile Image
    hatzbs
    Answered on November 11, 2015 at 05:09 PM

    Unfortunately, the field is not updating. Doesn't put in the age in the field. 

  • Profile Image
    hatzbs
    Answered on November 11, 2015 at 05:17 PM

    Well, I got it to work, sort of. :)

     

    -16706 is the value being shown. I'm doing something wrong... 

  • Profile Image
    Mike_G
    Answered on November 11, 2015 at 06:19 PM

    it is because you lack condition brackets in the formula of your condition. Here's how your condition looks like: 

    Here's how it should look like. 

    I hope this helps. Let us know if you need any further assistance. Thank you. 

  • Profile Image
    hatzbs
    Answered on November 11, 2015 at 10:00 PM

    Hi, are you on the support team? I don't think so, so your rude comments are not welcome. If you are on the support team, then I will be double thinking my subscription to your product.

    With that being said, it works. Many thanks to the support team for your assistance! 

  • Profile Image
    carolinaruggerfest
    Answered on March 11, 2017 at 11:26 AM

    Just came across this thread as I needed to know how to do this. Thanks Mike_G!

    hatzbs -- Not sure how you viewed his response as rude in any way shape or form. There is nothing about the response from Mike_G that even remotely seems rude.