Is there a way to calculate the total from the start time to the end time, and output the hours to the daily hours box

  • Profile Image
    cnumb
    Asked on September 21, 2015 at 04:23 PM
    One more question, is there a way to calculate the total from the start time to the end time , and output the hours to the daily hours box ?
  • Profile Image
    Boris
    Answered on September 21, 2015 at 07:36 PM

    Yes, you can set it up with some conditional logic, and assigning calculation values to hours in your drop down fields.

    I will walk you through setting it up for the first day of the first week, but the process is the same for all of them. So first thing we need to do is to assign calculation values to hours in the drop down fields. For field Sunday Start Time of week 1, I have added the following one:

    6
    6.5
    7
    7.5
    8
    8.5
    9
    9.5
    10
    10.5
    11
    11.5
    12
    12.5
    13
    13.5
    14
    14.5
    15
    15.5
    16
    16.5
    17
    17.5
    18
    18.5
    19
    19.5
    20
    20.5
    21
    21.5
    22
    22.5
    23
    23.5
    0
    0.5
    1
    1.5
    2
    2.5
    3
    3.5
    4
    4.5
    5
    5.5

    And for the End Time I have assigned the following calculation values:

    16
    16.5
    17
    17.5
    18
    18.5
    19
    19.5
    20
    20.5
    21
    21.5
    22
    22.5
    23
    23.5
    0
    0.5
    1
    1.5
    2
    2.5
    3
    3.5
    4
    4.5
    5
    5.5
    6
    6.5
    7
    7.5
    8
    8.5
    9
    9.5
    10
    10.5
    11
    11.5
    12
    12.5
    13
    13.5
    14
    14.5
    15
    15.5

    After setting them up, we can now use them in calculations. Basically, if user selects 9:30AM, calculated value of that option is 9.5, and 4PM calculates as 16.

    We then set up a calculation condition, by going to Setup & Embed > Conditions > Update a form field value, and setting it up to calculate End Time minus Start Time, and output it to Hours Today of these times:

    On the actual form, it will calculate to this:

    If you wish to prevent your users from submitting negative values (end time before starting time, such as they started at 9 AM but finished at 8 AM), you can set these calculations to use the MAX math function, and return the maximum value - either zero or that calculation.

    Here is a demo form with steps from above already implemented, but only for the Sunday of week 1. So only the first day is already set up on the demo form:

    http://form.jotformpro.com/form/52636830943965

    Please do let us know if you hit any snags along the way, and we will be happy to help.