How to calculate age?

  • Profile Image
    jskus
    Asked on September 20, 2015 at 12:00 AM

    in your forum when i put up date of birth age automatically not showing what is the process for this action kindly tell me?

  • Profile Image
    Amber 
    Answered on September 20, 2015 at 06:39 AM

    Would this be of any help?

  • Profile Image
    ashwin_d
    Answered on September 21, 2015 at 01:04 AM

    Hello jskus,

    Unfortunately, we do not have any widgets to calculate Age but with a little workaround it is possible to achieve your requirement.

    You can take advantage of our "Form Calculation" widget to calculate the age. Here are the steps you should follow:

    #1. Add a date time field in your form and set the default date as today's date.

    #2. Add another date time field where user can select date of birth.

    #3. Add "Form Calculation" widget in form and set the formula to calculate the age. Please check the screenshot below: 

     

    Hope this helps.

    Do get back to us if you have any questions.

    Thank you!

  • Profile Image
    jskus
    Answered on September 21, 2015 at 02:59 AM

    hello

       its working perfect but result of calculation is showing like 24.5, 26.7 etc how it will show in full figure like 24, 25 etc faction figure will not showing after calculation , kindly tell us.

  • Profile Image
    grade4pagasa
    Answered on September 21, 2015 at 03:41 AM

    hi jskus. 

    you just have to select "0" for decimal places within the form calculation wizard.

  • Profile Image
    ashwin_d
    Answered on September 21, 2015 at 07:14 AM

    Hello jskus,

    You will have to edit the "Form Calculation" widget and set the "Decimal Places in Numerical Results" property to "0". Please check the screenshot below on steps to make this change in the form calculation widget:

     

    Hope this helps.

    Do get back to us if you have any questions.

    Thank you!

  • Profile Image
    veshman
    Answered on October 10, 2015 at 01:46 PM

    I'm having trouble getting the correct Age in years. I've used the formula as shown, but the result I'm getting is not completely accurate. It's off by one year. Oddly, when the DOB month is before the current month, the age is higher, and when the DOB month is after the current month, the age is lower.

     

  • Profile Image
    ashwin_d
    Answered on October 11, 2015 at 06:26 AM

    Hello veshman,

    I have moved your question to a new thread and you will be answered here:  http://www.jotform.com/answers/678341020 

    Thank you!

  • Profile Image
    grade4pagasa
    Answered on October 12, 2015 at 01:09 AM

    hi veshman

    if you could share the age calculator (form) you created, the JotForm Support Team would be able to better assist you.  

    while waiting for the Support Team's reply / solution, i made a simple birthday calculator that you can play with. 

    *** i'm not a coder, so please bear with my logic & method :)

    i used the floor() function to round the age downward to its nearest integer. the number of days used in the calculation is 365.25 - so expect to see less than (+/-) 1 day rounding-error on the actual age. and to make things more hackneyed, it will display "Happy Birthday" when the current month & day falls on the birth month & day.

    it would be great if members of the JotForm Community (users) can share their alternative solution so we can compare notes.

    hope this helps for the meantime. 

    @ashwin_d:
    apologies for replying here. the new thread link you provided is broken (it's redirecting me to My Forms page).

    - Randy 

  • Profile Image
    ashwin_d
    Answered on October 12, 2015 at 07:14 AM

    Hello Randy,

    Thank you for your response here. 

    One of my colleague have also explained this in the other thread. The reason you are not able to open that thread because it is a private thread. 

    Thank you!

  • Profile Image
    drpatel
    Answered on October 12, 2015 at 11:01 AM

    Hi Randy, the other thread is redirecting me to My Forms as well. However, the formula he gave in that thread did indeed work, and it was using the floor() function as you did. 

     

    It was: floor ( ( todays date - birthday ) / 362.25 )

     

    Cool trick with the Happy Birthday. That's awesome! I'm importing the form to save for later!

     

    I had a brain fart and thought it was still having a calculation issue, but I was wrong. It was working perfectly. Thanks for the code.

     

     

  • Profile Image
    ashwin_d
    Answered on October 12, 2015 at 12:19 PM

    Hello drpatel,

    I am glad to know that the workaround shared in the other thread worked for you.

    Do get back to us if you have any questions.

    Thank you!

  • Profile Image
    grade4pagasa
    Answered on October 13, 2015 at 12:48 AM

    hi drpatel. i'm happy that you appreciate the simple birthday calculator. 

    here's the updated birthday calculator.

    btw, brain farts are actually important - it tells us that we need to take a break, even for just a short while, so we can think more clearly ;)

    - Randy