• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Total Time calculation manual entry of hours and minutes

Explorer ,
Sep 06, 2022 Sep 06, 2022

Copy link to clipboard

Copied

I'm experimenting with a time entry, but can't seem to find exactly what I'm looking for, as all the examples I've found are calculating time in and time out. I'm not sure it is the best way to do things in the first place.

 

The concept is there are two drop downs in one column-Hours and Minutes (in 5 minute increments). I do not foresee any user working more than 24 hours at a time, but you never know. At the bottom of the form is a TotalHours text field where the total of all entries (or no entries) is shown.

 

Example: On Row 1, 1 hours is selected and 25 Minutes is selected. On Row 2, 45 minutes is selected. The two combo boxes need to be combined (so Row 1 total would be 1:25 and Row 2 would be :45). Summing the two rows would equal 1:70 which would need to be converted to 2:10 in the Total hours.

 

How would one do this with minimal code? Would the options in the Hours combo be 0-23 or 0-24? The minutes combo is set to 0-60 in 5 minute increments.

 

Thanks. If this is a bad idea and just using a single text box with 1.25, etc. and summing the column of all rows is the better way, please say so. I have seen some web-based forms/apps that use the drop-down method above. Each row is a separate event/project just FYI. The event may span more than one day, but we are currently only entering total hours actually worked at the event, not by the day. So a three day event may be 8 hours one day and 4 hours another day, but which day doesn't matter. We have a column listing the date range that are combo boxes, so they are not an actual date field.

TOPICS
How to , JavaScript , PDF forms

Views

322

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 12, 2022 Sep 12, 2022

Copy link to clipboard

Copied

LATEST

Hi,

As you have the minutes separate it would probably make sense to add that up first and divide by 60 to get the number of hours, and then just add the to the hours, so using your example above

 

entryNum. hours mins

1                    1      25

2                    0      45

 

minutes current = 70

hours current = 70/10 = 1 (ignoring the remainder)

minutes total 70 - 60 = 10.

hours total = 1 + 1 (from mins) = 2.

 

result = 2 hours and 10 mins.

 

Hope this helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines