is it possible to calculate the number of years by using a 'Date Picker

  • Profile Image
    aaronchan
    Asked on December 28, 2020 at 10:50 PM

    is it possible to calculate the number of years by using a 'Date Picker' field vs a 'Date Picker Month Year' field ? Please advise



    This is a re-post of a comment on Mastering Date and Time Calculation

  • Profile Image
    Lorenz_A
    Answered on December 28, 2020 at 11:12 PM

    Thank you for contacting us.

    I believe the formula to calculate the difference in years between 2 date fields was explained in this guide https://www.jotform.com/help/443-mastering-date-and-time-calculation.

    Please give it a try and let us know how it goes.

  • Profile Image
    aaronchan
    Answered on December 28, 2020 at 11:26 PM

    Thanks Lorenz_A for the reply, unfortunately, what I am asking is about to calculate the difference in years between a 'Date Picker' field vs a 'Date Picker Month Year' field, which the calculation doesn't allow me to do so.

  • Profile Image
    Patrick_R
    Answered on December 29, 2020 at 12:19 AM

    Hello Aaronchan! If you're trying to calculate difference between two Date fields; then you can do this. The returned value would be in days. Here is an example form: https://form.jotform.com/203630934704957

    - what I am asking is about to calculate the difference in years between a 'Date Picker' field vs a 'Date Picker Month Year' field

    I am not very sure about what you mean by 'Date Picker Month Year' field. Can you please share your Form URL?

    We'll take a look and get back to you.

    Thank you!

  • Profile Image
    aaronchan
    Answered on December 29, 2020 at 02:18 AM

    Hi Patrick_R, here it is the form for your checking.

    https://form.jotform.com/203631189258055

    What am I trying to do is to calculate the Age, 'Course Date' of DD/MM/YYYY - "Date of Birth' of MM/YYYY.

    Please advise.

  • Profile Image
    ashwin_d
    Answered on December 29, 2020 at 03:39 AM

    With a little workaround, it is possible to achieve your requirement. Please take a look at the following cloned form where I have added few fields to calculate Age based on the widgets you have already added in form: https://form.jotform.com/203631391718960

    Feel free to clone this form for a closer look. The following guide should help you in form cloning: https://www.jotform.com/help/42-how-to-clone-an-existing-form-from-a-url

    Hope this helps.

    Do get back to us if you have any questions.

  • Profile Image
    aaronchan
    Answered on December 29, 2020 at 09:48 PM

    Hi ashwin_d, just tried your clone form, unfortunately the Age calculated is always zero, can you help to take a look again ? Many thanks.

  • Profile Image
    aaronchan
    Answered on December 29, 2020 at 09:58 PM

    Oh..., I got it, the Age field is set to be read only, that's why it doesn't show up, it works now, many thanks!!

  • Profile Image
    Vick_W
    Answered on December 29, 2020 at 10:02 PM

    I've just fixed the calculation for the Age field. Please try again and let us know if you need further assistance.

    Thanks

  • Profile Image
    Yau_C
    Answered on December 29, 2020 at 11:14 PM

    Hi Aaronchan,

    Please allow me more time to work on this and I will get back to you.

    Best,

  • Profile Image
    Yau_C
    Answered on December 29, 2020 at 11:38 PM

    Hi Aaronchan,

    I have created a form for you: https://form.jotform.com/203638194221957

    1609303071_5fec041f37fa9_

    You may clone my form and test it: https://www.jotform.com/help/42-how-to-clone-an-existing-form-from-a-url

    Best regards,

  • Profile Image
    aaronchan
    Answered on December 30, 2020 at 08:01 PM

    Hi Yau_C, thanks for the update, this calculated accurate. However, the course date supposed to be a pre-defined date by me, but the date of birth has to be input by the participant and it has to be month and year only not a full date. Is there anyway, I can manage to handle this requirement ? Please advise.

  • Profile Image
    Vick_W
    Answered on December 30, 2020 at 09:15 PM

    Hi there,

    My colleague used the Date Difference widget in the demo form. Unfortunately, it does not have the option to enter pre-defined data. Form user will have to select the date in this case.

    Thanks

  • Profile Image
    aaronchan
    Answered on December 30, 2020 at 09:39 PM

    Dear support,

    Let me recap my requirement once again, due to the confidentiality requirement, it only allows me to collect participant's date of birth with just month and year, not the full date. As of this, is there any way that I can calculate his/her age by comparing the course date (full date with day/month and year), which is pre-defined by me ? Pls advise.

  • Profile Image
    Vick_W
    Answered on December 30, 2020 at 11:09 PM

    Hi there,

    I've made some changes to Ashwin's demo form again. Please check it on the link below now.

    https://www.jotform.com/203631391718960

    Previously the decimals were showing in results. I've fixed the calculation again so that it will now show a round figure as per your requirement. Also, the Age field will only appear after the date of birth is entered.

    Here is how you can clone it.

    https://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL

    Let us know if you need further assistance.

    Thanks

  • Profile Image
    Vick_W
    Answered on December 31, 2020 at 12:57 AM

    I'm checking this for you and will get back to you shorlty.

    Thanks

  • Profile Image
    Vick_W
    Answered on December 31, 2020 at 01:30 AM

    We have to escalate this as a bug to the backend team. Please check the link below for the updates.

    https://www.jotform.com/answers/2794110

    Thanks

  • Profile Image
    Yau_C
    Answered on December 31, 2020 at 09:45 AM

    Hi AaronChan,

    I have modified my prototype for you with predefined course date: https://form.jotform.com/203638194221957

    You can define your course date behind the scenes:

    1609425598_5fede2bec740b_

    I understand that you need to protect the privacy of your user and only want to allow them to enter the month and year of the date of birth. You could do so by providing description as an instruction for the user to follow.

    Best,