Using Form Calculation to determine midway point between dates

  • Profile Image
    Asked on February 13, 2015 at 12:47 PM


    I have two required date fields in my form that once completed, should populate a third date field which would be the midpoint between the two.

    The first required field is the date the form is submitted(we'll call it "A"), the second date is the date of my clients affair (call it "B").

    I've used the calculation wizard to successfully populate when the final payment is due (using datestring(weddingdate-14), but for the life of me, clearly lack the mathematical prowess to even know where to begin creating a formula that will take Date "A" and Date "B" and spit back the correct 2nd due date which would be the midpoint between "A" & "B"

    I've attached a partial clone of the relative info for the form I'm working on

    is this even possible???

    thank you in advance

  • Profile Image
    Answered on February 13, 2015 at 03:06 PM

    Yes, it is possible, but we need to set it up correctly.

    First, this is the jotform where you can see it in action:

    Now what I did here:

    You have mentioned that you want to get a middle date. It would be easier if it is a certain amount of days, but even with this we are able to use Form Calculation and have it all work for us.

    First it is important to note that if we take the 'bigger' date {field1} and subtract the younger (past) date {field2} we will get the number of days in between {x}.

    Based on how you set the jotform I believe you already know the rest, but I will still continue :)

    Now setting the number of days as {x} and the middle date as {y} the function to get it becomes:

    y = field1 - x or y = field2 + x

    Lets put it into graphics

    In our case, we took the wedding date and subtracted the half of the days in between.

    Now since today is 13th, I would recommend setting the wedding to 27th to see the middle as 20 (the quick check), but do feel free to make all sorts of checks to see how it works.

    Do let us know how it goes :)

  • Profile Image
    Answered on February 13, 2015 at 03:22 PM

    Thanks Ben - think that might sort an issue I'm having too

  • Profile Image
    Answered on February 13, 2015 at 04:14 PM

    brilliant! Thank you Ben. It works perfectly

  • Profile Image
    Answered on February 13, 2015 at 04:19 PM

    I am very glad to see Ben's workaround helped not only one, but two Jotform users