Is it possible to calculate hour and minutes differences?

  • annieprice
    Asked on December 4, 2020 at 5:39 AM

    Hi there, please can you help me create a monthly timesheet for my staff that calculates the total hours each day along with a running total at the end of the month.

    I am attaching my excel form that I created but I really need an online version as a lot of my staff dont have access to excel.

    Thanks In Advance

    Annie Price

    Jotform Thread 2744723 Screenshot
  • Richie JotForm Support
    Replied on December 4, 2020 at 7:02 AM

    It is possible to create a timesheet form.

    You can add a time field

    1607083349 5fca25559c712 2 Screenshot 10


    and use the form calculation widget to calculate the total hours work.

    https://www.jotform.com/help/259-how-to-perform-form-calculation-using-a-widget

    Example calculation.

    1607083235 5fca24e320c19 2 Screenshot 21

    Sample Form:https://form.jotform.com/203382751319051

    Please check it out and let us know if this fits your requirements.

  • annieprice
    Replied on December 4, 2020 at 7:48 AM

    Hi, many thanks for this but the total amount is not accurate, I think its working it out as a percentage of time as opposed to total hours.

    Thanks


    Annie Price


  • Sonnyfer JotForm Support
    Replied on December 4, 2020 at 8:27 AM

    Hello Annie - Did you mean the total hours are not accurate? I did test the demo form of my colleague @Richie_P and it seemed to work fine. The total hours are calculating correctly as I change the end time.

    1607088328 5fca38c84175e tot Screenshot 10

    Could you please check again? If you're expecting a different result, kindly share some more information we can point you in the right direction.

  • annieprice
    Replied on December 4, 2020 at 8:31 AM

    Hi I have attached what happens on mine, thank you.1607088697 5fca3a39d8805 Screenshot 2020 Screenshot 10

  • Jessica JotForm Support
    Replied on December 4, 2020 at 9:30 AM

    Hi Annie, thank you for clarifying it to us.

    To calculate hour and minute differences, you will need to have four Form Calculation.

    • Hour differences
    • Total minutes
    • Minutes differences
    • Total hour and minutes

    Please kindly refer to the following demo: 203383357278967. Please give it a try too. If it's suitable, please kindly follow the steps below:


    Hour differences

    To calculate hour differences, we simply need to use the formula: floor(EndTime - StartTime). 

    1607092115 5fca4793b4796  Screenshot 10


    Total minutes

    To calculate minute differences, we will need to know the total minutes. We can calculate total minutes by using the formula: (EndTime - StartTime)*60.

    1607092133 5fca47a5c9396  Screenshot 21


    Minutes differences

    After calculating the total minutes, we can calculate the minute differences. We can simply use the formula: (HourDifferences* 60 - TotalMinutes)*(-1).

    1607092142 5fca47aeaaa62  Screenshot 32


    Total hour and minutes

    After calculating minutes differences, we can add them side by side. To do this, we simply need to use the formula HourDifferences : MinutesDifferences.

    1607092153 5fca47b96a911  Screenshot 43


    The form calculation of hour differences, total minutes, and minutes differences can be hidden from the form. So only the form creator will be able to see it in build.

    You may also clone the form by following our guide here: How to Clone an Existing Form from a URL.

    Let us know if it doesn't work for you.


    Related guide:
    How to Perform Form Calculation Using a Widget

    Form Calculation - Math Function Reference


  • annieprice
    Replied on December 4, 2020 at 10:57 AM

    Hi, thank you so much for this, I ha1607097439 5fca5c5f504d7 jotform downloa Screenshot 10ve tried this on my computer and it works well but on my phone it does not.

    Please see attached screenshot.

    Thanks

    Annie Price


  • Ashwin JotForm Support
    Replied on December 4, 2020 at 12:02 PM

    I did test your form and I see the issue you are having. It seems the calculation is not refreshed until the AM/PM is selected again in mobile device.

    I would suggest you to please test the following form in your mobile device and see if it displays the calculation correctly: https://form.jotform.com/203384855339969

    Do get back to us if the issue persists.

    We will wait for your response.

  • sgtwijanarko23
    Replied on December 4, 2020 at 2:36 PM

    Hi Annie,

    As a fellow JotForm user, I am also interested in this timesheet, someday I might need it. My approach would be using:

    1) Single Choice from Basic Form Element: Time Range and Duration Indicator,

    2) Form Calculation, the problem when adding duration from Time Range element it doesn't calculate correctly, that's why I use hidden text elements to abstract hours, minutes need conversion and join them back.

    It can calculate more than one date, in this form I made it to calculate two dates.

    3) Form Designer to position date and time so they're inline.

    4) Condition - Form Setting.

    I haven't figured out how to create a button for the user to calculate the time, currently using the radio button.

    1607213064 5fcc20082bd9a ezgif Screenshot 10

    https://form.jotform.com/203384630162045

    Anyway, I hope it helps.

    Sigit W.


  • annieprice
    Replied on December 5, 2020 at 6:14 AM

    Hi, thank you so much for this.

    My only problem is that I need 31 start time and end time fields so that my staff can complete one for each day of each month and then one for breaks each day with start time and end time.

    I have looked at your guidance above but its just too much for me !!


    Thanks


    Annie


  • Patrick_R
    Replied on December 5, 2020 at 9:39 AM

    Hi! Please allow me some time to look into this. I'll get back to you soon with an update.

    Thank you!

  • Patrick_R
    Replied on December 5, 2020 at 9:52 AM

    Hello!

    - My only problem is that I need 31 start time and end time fields so that my staff can complete one for each day of each month

    In that case, you'll need to copy/paste fields and formulas 31 times so that your staff members can provide the values 31 times.

    Following is a simple example on how you can do this: https://drive.google.com/file/d/1YxEOc3aScgVwN6EBiJNTu9Y-3jtlnnuM/view?usp=sharing

    This is the form prepared in this example: https://www.jotform.com/203393675878977

    - and then one for breaks each day with start time and end time.

    For including lunch breaks in your worksheets as well, you'll need to make some changes to your form.

    Please check this form: https://form.jotform.com/203393591005956

    I modified my colleague @Ashwin's form to include break times in it. The calculation now considers break times as well.

    If this solves your purpose, then you can clone this form into your own account and start using it by adding 31 fields to it, don't forget to copy/paste formulas as well (like demonstrated in the above screencast).

    I hope this information helps. for any further queries, feel free to write back to us.

    Thank you!