How can I calculate the difference between two time fields?

  • systemstrainingdesign
    Answered on February 19, 2018 08:22 PM

    Hi Guys

    I am trying to calculate total hours on my form using Form Calculation widget but I cant seem to get the formula right to be able to do that. 

    Do we have something that I can use?

    1519089708Screen Shot 2018 02 20 at 9 Screenshot 0

    Thank you in advance

  • Jim JotForm Support Manager
    Answered on February 20, 2018 02:48 AM

    Your screenshot shows you're using the CONFIGURABLE LIST WIDGET. Sadly, you can't use widgets in general for calculations. I understand your goal is to get the total hours worked based on your user's input, correct?

    This can be done using the regular TIME FIELD and the FORM CALCULATION WIDGET.

    Here's a quick example:

    When you subtract 2 time fields, the default result will be in decimal format, where the decimal place is the remaining minutes for the difference. I'm assuming you need it to show the actual difference (in minutes format) so you need to perform an additional calculation.

    And that is to convert the decimal place into minutes. This can be achieved by getting the decimal place, then multplying it back to 60 (to get the minutes value). You will better understand what I'm talking about if you will clone my test form.

    Related guide: How-to-Clone-an-Existing-Form-from-a-URL

    Afterwards, refer to this very detailed guide on how to perform calculations between two date or time fields.

    Complete guide: Mastering-Date-and-Time-Calculation

    If you're trying to do something else entirely, kindly get back to us with more info and a better description of what you're trying to achieve so we can better assist you.

  • systemstrainingdesign
    Answered on February 20, 2018 03:19 AM

    Thank you Jim, yes i was trying to get total hours calculated.