How do I calculate the difference between todays date and a date set in the future that is hidden in the form?

  • ryandonald
    Asked on March 16, 2015 at 5:07 PM

    I am trying to calculate how many days there are from the day the customer sees my form to 02/11/2015 2nd november which will remain hidden. How can I modify the script to allow me to change and set this date? 

    Cheers

    Ryan

  • jonathan
    Replied on March 16, 2015 at 7:47 PM

    Hi Ryan,

    If you check this JotForm Calculate Number of Days template, you will see how it calculates the number of days between 2 dates.

    As you can see, it will be simple to calculate the days difference between two dates using the Date field.

    BUT if I am not mistaken, from what I understand on your description, you wanted the future input date to be hidden on the form?

    In your form http://www.jotform.co/form/50741458971866, the user should not be able to manually input the future date?

    Can you please clarify first if my understanding of the procedure is correct.

    We will provide with you with the applicable solution when this is clear.

    Thanks.

     

     

  • ryandonald
    Replied on March 16, 2015 at 8:41 PM

    Yes that is correct, I need the future input date to be hidden

    Awesome thankyou 

  • jonathan
    Replied on March 16, 2015 at 10:31 PM

    You can achieve this by following these steps:

    #1. Add a hidden DateTime field on the form.

    How do I calculate the difference between todays date and a date set in the future that is hidden in the form? Image 1 Screenshot 60

    #2. Create the needed Calculation between 2 dates.

    How do I calculate the difference between todays date and a date set in the future that is hidden in the form? Image 2 Screenshot 71

     

    #3. Make sure first the calculation is working as needed. The fields can be hidden also using the Hide Property

    How do I calculate the difference between todays date and a date set in the future that is hidden in the form? Image 3 Screenshot 82

     

    How do I calculate the difference between todays date and a date set in the future that is hidden in the form? Image 4 Screenshot 93

     

    --

    the question now is.. how will you be able to fill-in the future dates if it is hidden on the form?

     

    #4. You can pre-fill the hidden Date (future date input) using the pre-populate URL method.

    user guide: -Prepopulating-fields-to-your-JotForm-via-URL-parameters

    How do I calculate the difference between todays date and a date set in the future that is hidden in the form? Image 5 Screenshot 104

     

    You can test my demo form. I have hidden the future Date and show only the Total Days so that you can see the calculation. 

    http://www.jotformpro.com/form/50747056708965?futureDate[month]=05&futureDate[day]=23&futureDate[year]=2015

    Hope this help. Let us know if you need further assistance.

    Let us know if this solution work.. or not.

    Thanks.