Calculations on Multiple Date Pickers

  • ChintiminiKC
    Asked on March 18, 2025 at 5:50 AM

    I need to write a form to calculate the number of days a booking is being made. I tried one of your templates but it allows an arrival date to be after a departure date. The number of days of the stay is then calculated as a negative number. Do you have a widget that allows a range of date to be entered that prevents this error?


  • Shaina JotForm Support
    Replied on March 18, 2025 at 9:32 AM

    Hi Nick,

    Thanks for reaching out to Jotform Support. I’ll need a bit of time to look into this. I’ll get back to you as soon as I can.

    Meanwhile, Let us know if you have any other questions.

  • Shaina JotForm Support
    Replied on March 18, 2025 at 11:18 AM

    Hi Nick,

    I cloned your form and tested it to see if I could replicate the issue, and I ran into the same issue. When I looked at your form, I saw that the allow selection of start and end date of the date picker widget wasn't configured correctly. Let me show you how to fix it:

    1. In Form Builder, click on the Gear icon of Date Picker widget.
    2. Click on Limits option in the option panel that pops up in the right part of the page.
    3. Scroll down and set up the date of Start & End Date option.

    Calculations on Multiple Date Pickers Image 1 Screenshot 30

    Check out the screencast below to see my results:

    Calculations on Multiple Date Pickers Image 2 Screenshot 41

    For more details on performing date and time calculations, you can refer to this guide.

    Give it a try and let us know if you need any other help

  • ChintiminiKC
    Replied on March 18, 2025 at 1:10 PM
    Here’s the problem. I set the limits for the Date From to be arriving either the Wednesday, Thursday, Friday or Saturday of the first week in April (2nd to 5th.). The date to is limited to be Thursday, Friday, Saturday and Sunday (April 3rd, 4th, 5th and 6th) allowing a 1, 2, 3 and 4 day stay. But if the dates are entered incorrectly like shown in the screen shot, the calculated days of stay is -1. I can fix the calculation by using an absolute value, but the arrival day and departure day will not make sense. Most hotel forms I have seen allow a date range to be selected from one window of a calendar. This would eliminate the problem???
    Thanks
    Nick
    Nick Pisias
    Corvallis Oregon
    ngpisias@gmail.com

    ...
  • ChintiminiKC
    Replied on March 18, 2025 at 1:40 PM
    Shaina: I found another error in your form. Here are two screen shots. I set up the start and end dates to have a default date (screen shot one). But when I run the form, today’s date is the default. How do I fix this?
    thanks
    Nick
    
    Nick Pisias
    Corvallis Oregon
    ngpisias@gmail.com
    ...
  • ChintiminiKC
    Replied on March 18, 2025 at 2:05 PM
    Shaina: One more problem. Here is a screen shot of a form where I entered an arrival date and a departure date, three days apart. The calculation was made that gave 3 days. But I could enter the number of days as 1. I have found this error with other of my forms. To prevent changing the calculation I hid the field. But is there a way to show the results of the calculation but to lock the field so it cannot be changed?
    Thanks
    Nick
    Nick Pisias
    Corvallis Oregon
    ngpisias@gmail.com
    ...
  • Eliza JotForm Support
    Replied on March 18, 2025 at 3:58 PM

    Hi Nick,

    The screenshots you tried to attach are not visible on our end. We’ve got a guide here that’ll show you how to post a screenshot to our Support Forum. Also, are you working on this form? If no, can you share with us the URL of the form that you're working on? Let me show you where to find the form URL:

    1. On your My Forms page, hover your mouse over the form and click on More on the right side of the page.
    2. Under the Publish column, select Publish Form.
    3. Click on the Copy Link button.

    Calculations on Multiple Date Pickers Image 1 Screenshot 20

    Once we hear back from you, we'll be able to help you with this.

  • ChintiminiKC
    Replied on March 18, 2025 at 4:05 PM
    yes, i am working on the form linked to “this form”. thanks Nick
    Nick Pisias
    Corvallis Oregon
    ngpisias@gmail.com
    ...
  • ChintiminiKC
    Replied on March 18, 2025 at 4:30 PM

    Here's the screen shot to show the problem. The dates entered should show 16 days in the Calculations. But I was able to change the number to 0. The only way to prevent this is to hide the Calculation number. Can the number of days be shown, but have the field locked.

    Calculations on Multiple Date Pickers Image 1 Screenshot 20

  • ChintiminiKC
    Replied on March 18, 2025 at 5:13 PM

    thanks for the help, but I found a simpler way to solve the problem. Our events are always Thursday, Friday, Saturday and Sunday of the week. Here's link to my form that I set up to make entry simpler. I still have the problem that if the number of days is not hidden, the user can change the field.Calculations on Multiple Date Pickers Image 1 Screenshot 20

    I added the link to this message (https://form.jotform.com/ChintiminiKC/new-rv-space-reservations)


    again, thanks

    Nick


  • Shaina JotForm Support
    Replied on March 18, 2025 at 5:52 PM

    Hi Nick,

    We received your message, but it looks like the screenshots you mentioned weren’t attached. Could you please resend them so we can take a look? If you can take a screenshot of what’s happening, that will help us to understand better. Let me show you how to post a screenshot to our Help Center:

    1. On the Help Center page, scroll down to the Your Answer section and click on the Image icon.

    2. Drag and drop your image into the Upload box, or click on it and select your file.

    3. Then, click on the Add button in the bottom-right corner of the window.

    Calculations on Multiple Date Pickers Image 1 Screenshot 40

    4. To resize it, click on your screenshot and then click on one of the boxes in the corners, and drag inward.

    5. Once you're finished, click on the Post Answer button at the bottom right of the Your Answer section.

    Calculations on Multiple Date Pickers Image 2 Screenshot 51

    Also, I cloned and tested your form, and I noticed that the number of days was hidden already. Take a look at the screenshot below to see my results:

    Calculations on Multiple Date Pickers Image 3 Screenshot 62

    Once we hear back from you, we'll be able to help you with this.

  • ChintiminiKC
    Replied on March 18, 2025 at 6:14 PM

    That is correct. Unhide the number of days calculated and you can change the number in the form. Here's link to a form where I collect entries to an American Kennel Club event (https://form.jotform.com/ChintiminiKC/may-fastcat-entry). If I unhide the amount field, I have had people zero out the fee calculations to enter the event without paying. Here it doesn't matter much because the fees show up in the payment window. But for the RV space rental having the number of days booked is useful. But having someone change the number is a problem. Can I lock a calculated value so it can't be changed?

    thanks


  • Shaina JotForm Support
    Replied on March 18, 2025 at 7:12 PM

    Hi Nick,

    You can lock the Form Calculation widget from editing by changing the result field to read-only. Let me show you how:

    1. In Form Builder, click on the Wand icon of Form Calculation widget.
    2. Click on Option in option panel that pops up in the right part of the page.

    Calculations on Multiple Date Pickers Image 1 Screenshot 40

    3. Click on the Checkbox of Result field is read only at the option list.
    4. Click the Go back button in the right part of the page.

    Calculations on Multiple Date Pickers Image 2 Screenshot 51

    5. Click on the Save button.

    Calculations on Multiple Date Pickers Image 3 Screenshot 62

    Give it a try and reach out again if you have any other questions.