How can i calculate the time difference in this form?

  • princess5510
    Asked on February 16, 2021 at 2:27 AM

    Hi, my company wants me to create a time sheet just like this form,

    this is a template and i was unable to figure out the coding behind the monday timings.

    I created the code for the tuesday timings but however, the total hours being calculated are a little messed up. When i enter tuesday clock in timing as 9:45 am to clock out timing being 3:15 pm, it shows the total hours being calculated as -6.30 hours where as it the total hours should show 5.30 hours.


    Can anyone fix this issue?

    Thanks in advance.

    https://www.jotform.com/build/210333129767455#preview

  • roneet
    Replied on February 16, 2021 at 3:53 AM

    Please allow me some time to take a look at it.

    Thanks.

  • roneet
    Replied on February 16, 2021 at 7:41 AM

    Could you please check if this demo form would work for you:

    https://form.jotform.com/210461940103947

    Let us know how it goes.

    Thanks.

  • princess5510
    Replied on February 20, 2021 at 3:05 AM

    Hi roneet this demo works,

    but i want the outline of my form just like this form

    https://www.jotform.com/build/210333129767455#preview

    i want the employees to be able to select time in just one drop down not in seperate text field.

    Hope this clarifies.

    Thank you.

  • Patrick_R
    Replied on February 20, 2021 at 2:10 PM

    Hi!

    - I created the code for the tuesday timings but however, the total hours being calculated are a little messed up. When i enter tuesday clock in timing as 9:45 am to clock out timing being 3:15 pm, it shows the total hours being calculated as -6.30 hours where as it the total hours should show 5.30 hours.

    Kindly note that there is no Time field form the Input table. So, the dropdown values here are basically the decimal values for JotForm. the colon (:), 'AM' and 'PM' are discarded as these are not the part of number values; the calculation then becomes: (315 - 945) / 100 = -6.3

    So, the calculation is correct; but this is as per the decimal values.

    The best method to calculate time is actually with the Time field itself. The solution provided above by my colleague should solve the purpose.

    Our apologies for the inconvenience.

    Thank you!

  • Patrick_R
    Replied on February 20, 2021 at 2:20 PM

    Hello! There is another way, in which less number of calculations are involved. Basically, in our Time field, we offer automatic duration calculation; you can enable 'Time Range' and 'Duration Indicator' for time fields and that should solve your purpose.

    1613848807 603160e7e4847 The Easiest Onl Screenshot 10

    As an example, please check this form: https://form.jotform.com/210505219433951

    In this demo form, as you choose the date ranges, total time is displayed on the right side. At the bottom, all time is calculated to give a final working time.

    Please check, if this solves your purpose, you can use it instead.

    Thank you!

  • princess5510
    Replied on February 22, 2021 at 10:18 AM

    Hi roneet.

    I have cloned the conditions of this waste timesheet form https://form.jotform.com/210517035598962

    to my form ; URL: https://www.jotform.com/build/210524397919059#preview

    However my forms time calculation dont seem to be working even if i have copied the exact conditions.

    1614007035 6033cafbc0a0b 1 Screenshot 10

    The problem is, my results table is unable to extract info for clock in text field and calculate the time.

    Can you check pls? thanks

  • Nikola JotForm Support
    Replied on February 22, 2021 at 11:57 AM

    It seems that you resolved the issue.

    1614012880 6033e1d0f04a4  Screenshot 10

    If I did not understand properly what is the issue, please provide us more details.

    I would also suggest you check the following guide: Mastering Date and Time Calculation