Calculating Date with Time

  • mfrittenburg
    Asked on April 15, 2025 at 4:47 PM

    My Vehicle Registration -Parking Permit Form

    I am trying for the following:

    Once someone clicks on "Hourly" the "Submitted At" should automatically calculate + 4 hours and output the result on the Thank You page with the Date and Time (4 hours from the time of submission)

    If someone clicks on the "Overnight" the "Submitted At" should automatically calculate +24 hours and output the result on the Thank You page with the Date and Time (24 hours from the time of submission) but I can't seem to get it to work. I believe my calculations are correct but they don't seem to be working.

    I think the 4 hour might be working but, not the 24 hour.

  • Deanne JotForm Support
    Replied on April 15, 2025 at 6:02 PM

    Hi Melissa,

    Thanks for reaching out to Jotform Support. I checked your form and your calculations are correct. The reason why your 24 hours is not giving the correct result is because in its formula, you're already adding 1 to it:

    Calculating Date with Time Image 1 Screenshot 50

    And in the condition, you added another 1 again:

    Calculating Date with Time Image 2 Screenshot 61

    That is why instead of adding only 1 day, it's adding 2 days:

    Calculating Date with Time Image 3 Screenshot 72

    Remove the +1 in the condition and it should give you the correct value. As for the Thank You page conditions, I see that it is also configured correctly. Just one thing you need to update is the Limit of your Formatted 24 Hour Expiry field. Make sure to check either one of these and your form should be working as expected:

    Calculating Date with Time Image 4 Screenshot 83

    Reach out again if you need any more help.

  • mfrittenburg
    Replied on April 16, 2025 at 1:23 PM

    Hello,

    Sorry it's still not working for the 24 hour. It's giving the same day and the 4 hour time frame.

  • Deanne JotForm Support
    Replied on April 16, 2025 at 2:20 PM

    Hi Melissa,

    I cloned your updated form and showed the hidden fields for testing purposes, and it's showing +1 day and +4 hours on my end:

    Calculating Date with Time Image 1 Screenshot 20

    Can you take a screenshot of what you're seeing on your end and send it to us? This guide will show you how to do that.

    Keep us updated and let us know if you need any more help.

  • mfrittenburg
    Replied on April 16, 2025 at 2:31 PM

    It should only show 24 hour time frame difference when Overnight is selected. Also on the Thank You page, it's not updating with the correct 24 hour date/time.

    Calculating Date with Time Image 1 Screenshot 30

    Calculating Date with Time Image 2 Screenshot 41

  • Deanne JotForm Support
    Replied on April 16, 2025 at 3:51 PM

    Hi Melissa,

    I checked your form again and I noticed in your 24 Hour Calculation formula, the +1 was removed:

    Calculating Date with Time Image 1 Screenshot 40

    Add it back, and your 24-hour time frame result should be correct. As for the Thank You page, it shows the wrong condition since the condition below is still true even if the form user selected the Overnight option:

    Calculating Date with Time Image 2 Screenshot 51

    Update it to this condition instead:

    Calculating Date with Time Image 3 Screenshot 62

    And that's it. Here's also my demo form that you can clone and check out.

    Let us know if you need any other help.

  • mfrittenburg
    Replied on April 16, 2025 at 5:11 PM

    Now my 4 hour thank you page doesn't show anything since I updated it as you mentioned.

  • mfrittenburg
    Replied on April 16, 2025 at 5:18 PM

    24 hour thank you page seems to be working..off by a couple minutes but that is okay. If we can figure out how to get it on time as I know some could complain about that, that would be great but not the end of the world. However, the 4 hour is not working now with your last update suggestion.

  • Deanne JotForm Support
    Replied on April 16, 2025 at 5:30 PM

    Hi Melissa,

    Here's the condition you set:

    Calculating Date with Time Image 1 Screenshot 30

    The correct one is this:

    Calculating Date with Time Image 2 Screenshot 41

    As for the accuracy of the time, I’ll need a bit of time to work out a solution. I’ll get back to you shortly.

    Let us know if there’s anything else we can help you with.

  • Deanne JotForm Support
    Replied on April 16, 2025 at 6:02 PM

    Hi Melissa,

    I did some tests and found a solution for the accurate time. You don't need these Form Calculation fields, so you can delete them if you want to:

    Calculating Date with Time Image 1 Screenshot 50

    As for the conditions, you can delete the existing ones and replace them with these conditions instead:

    Calculating Date with Time Image 2 Screenshot 61

    Calculating Date with Time Image 3 Screenshot 72

    Here's a sample result:

    Calculating Date with Time Image 4 Screenshot 83

    Here's my updated demo form that you can clone and check out.

    Reach out again if there’s anything else we can help you with.

  • mfrittenburg
    Replied on April 17, 2025 at 1:46 PM

    It didn't calculate the correct time, still off by a bit:

    Calculating Date with Time Image 1 Screenshot 30

    However, the 24 hour is right on target.

    Calculating Date with Time Image 2 Screenshot 41

  • Deanne JotForm Support
    Replied on April 17, 2025 at 2:35 PM

    Hi Melissa,

    I cloned your updated form and it gave me the correct time. See my screenshot below:

    Calculating Date with Time Image 1 Screenshot 20

    This could be a temporary issue, so I've cleared the form cache to fix any possible cache issues in the form. Can you try again and see if it now gives the correct time?

    Give it a try and let us know how it goes.

  • mfrittenburg
    Replied on April 17, 2025 at 3:28 PM

    That worked! Thank you.

Your Answer