Date calculations malfunctioning

  • mediprofirstaid
    Asked on March 18, 2023 at 2:33 PM

    The DateString calculation is removing a day from baseline date.

  • Mohamed JotForm Support
    Replied on March 18, 2023 at 7:16 PM

    Hi Jason,

    Thanks for reaching out to Jotform Support. When I cloned and tested your form, the same thing happened for me. After investigating it a bit, I found a solution. It's really easy to fix. Let me show you how:

    • Click on the icon gear to open the Properties of the Schedueled Course Start Dates.
    • Go to Options and activate the Calculation Values.
    • Add 2023-04-10 in the first field and 2023-05-15 in the second field.

    1679181204 641645940f755  Screenshot 10

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

  • mediprofirstaid
    Replied on March 20, 2023 at 2:17 PM

    Hi Mohamed,

    The "Calculation Values" in the Radio dropdown options are not the issue. I tried using the calculation values you're suggesting during my initial chat support session. This was ruled out as a solution. The system appears to be functioning in your video demonstration because I've adjusted the corresponding conditional calculations to add one day. This compensates for the bug which is automatically removing a day.

    As you can see, Session A date is currently based on Start Date plus 1. The result is that Session A is May 15th. However, if I remove the "+1" from the calculation, the resultant output is May 14th (one day less than the Start Date field. The system is incorrectly subtracting a day from the calculations, and I'm only able to achieve the correct dates on the form by adding extra days to the calculations. This is a workaround but it shouldn't be necessary and will likely create the opposite issue if/when the bug resolves itself.

    1679336038 6418a26666a72  Screenshot 10

  • Mohamed JotForm Support
    Replied on March 20, 2023 at 5:32 PM

    Hi Jason,

    I’m sorry you're having difficulties getting that feature to work. I have cloned your form again, and I think that you have resolved the issue properly. Based on the condition you provided using +1, this means that Session A date should be April 11, 2023 and May 16, 2023 which is working exactly after cloning your form.

    I only did unhide the IDP Program Type, Start Date and Session A Date fields to be able to test the logic. I found it is working properly and you can check the below results showed in the screencast:

    1679347766 6418d0360b843  Screenshot 10

    In case I misunderstood the logic you need to reach, could you explain more what do you expect to have in Session A Date when the IDP Program Type is filled?

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

  • mediprofirstaid
    Replied on March 20, 2023 at 7:21 PM

    Hi Mohammed,

    The calculations are not performing correctly. I'll use May 15th for this explanation, but it also applies when April 10th is selected.

    Here is the data path that "normally" occurs....

    Input from the Radio buttons (Scheduled Instructor Dates) is transferred via a calculation condition to the Date Picker field "Start Date".

    If "May 15, 2023 (Willow Creek Fire Dept) is selected with the calculation value of 2023-05-15 on the Radio Button, the Start Date field becomes 2023-05-15. That part is working.

    The hidden field "Session A Date" is a text field that is filled as a dateString based on Start Date. A conditional logic calculation normally transfers the output of "dateString (Start_Date)" to Session A Date. Since "Start_Date" is 2023-05-15 this should result in a text formatted date of "Mon May 15 2023" in "Session A Date". Session A should be the same date as Start Date.

    However that calculation output is producing Sun May 14 2023 instead. Even though the Start Date is going into the datestring calculation as 2023-05-15, the datestring output is one day less (May 14).

    As previously mentioned, I currently have the Session A Date calculation set up to compensate for this as "datestring (Start_Date + 1)" which is producing the desired output of Mon May 15 2023. However, the +1 should actually make it May 16 if the system was functioning properly. The +1 is compensating for the inherent miscalculation, but it should not be necessary. 2023-05-15 + 1 should be Tue May 16 2023, but it is currently producing Mon May 15 2023.

    I have similarly adjusted calculations for Session B Date, Session C Date, Session D Date, and Session E Date as datestring (Start_Date +2, +3, +4, +5) to produce successive days, but each time I'm having to add one more day than should be necessary.

    The system is not performing the calculations correctly, it is subtracting a day from every calculation. I've got the current calculations set up to compensate for this but it shouldn't be necessary and was not necessary until a few days ago.

    Your cloned form is performing differently from my live form.

  • Marlon_T Jotform Support
    Replied on March 21, 2023 at 1:24 AM

    Hi mediprofirstaid,

    Going back to your main concern, I've tried to clone and follow your instructions, and the form everything works the way it should. Would you be able to provide the entire flow of the conditions so we can figure out if other fields we're affected or not?

    Before we proceed, I would like to confirm some information from your statement:

    • Does the issue persist for May 15 and April 10 on your end only?
    • For every increment of the session from A, it should be always +1.

    Also, please provide a screen recording or screencast while testing the form on your end in order for us to figure out and visualize what's causing the error on your end.

    Once we hear back from you, we can move forward with a solution.