Date time calculation

  • Profile Image
    labman3
    Asked on November 03, 2016 at 01:24 PM

    I'm trying to calculate the number of hours worked on a completed work request. I used the calculations found in the forum, but it's not accurate. i.e. if i enter START time as: 11/2/2016 at 2:10pm and the END time as: 11/2/2016 at 9:30pm, the value returned is 7.33hrs, but it should be 7.2hrs.

    https://www.jotform.com/?formID=62984942194166

  • Profile Image
    Jim_R
    Answered on November 03, 2016 at 03:00 PM

    Hello, the calculation is correct. In 1 hour, there's a total of 60 minutes, thus 6 iterations of 10-minute stepping.

    The first 10 min mark is equivalent to 1/6, which is equal to 0.1666666666666667 (rounded off to .17). Then 2/6, 3/6 and so on.

    Here's the complete breakdown of each 10 minute stepping:

    10 mins = .17 (1/6)

    20 mins = .33 (2/6)

    30 mins = .5 (3/6)

    40 mins = .67 4/6)

    50 mins = .83 (5/6)

    60 mins = 1 (6/6)

    So, 9:30pm - 2:10pm = 7.33

    If we'll convert .33 to minutes it will be:

    2 / 6 = 0.3333333333333333

    0.3333333333333333 * 60 = 20 mins

  • Profile Image
    labman3
    Answered on November 03, 2016 at 05:16 PM

    how would i calculate the so the time is 7hrs 20min?

  • Profile Image
    Jim_R
    Answered on November 03, 2016 at 07:02 PM

    Feature/option-wise, no there's no way to achieve that. But I'm currently looking for a workaround.

    I can probably use Conditions to achieve something similar so allow me some time to come up with something. I'll get back to you on this same thread. :)

  • Profile Image
    Jim_R
    Answered on November 03, 2016 at 07:42 PM

    All right, can you check my test form: https://form.jotform.com/63077719135965

    Here are all the things I did:

    1. I hid your Hours form calculation and named it Hours (Temp).

    2. I added 2 Textboxes (1 for Hours and 1 for Minutes)

    3. I used the floor() function to round off the Hours (Temp) value then push the whole number to the Hours Textbox.

    4. Then I setup the conditions for each of the results of the 10-minute stepping (.17 for 10 min, .33 for 20 mins, and so on).

    RESULT:

    You can also clone my form if you wanted to see how it was setup, here's how.

    Let me know if that works for you :)

  • Profile Image
    labman3
    Answered on November 04, 2016 at 07:59 AM

    it works!! thank you very much.