• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Calculating hours worked|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Calculating hours worked|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…Calculating hours worked
sp_PrintTopic sp_TopicIcon
Calculating hours worked
Avatar
Michael Flanagan

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
January 12, 2020
sp_UserOfflineSmall Offline
1
January 12, 2020 - 4:49 am
sp_Permalink sp_Print

Hi, I have a question regarding calculation of hours worked.  The employees use a GPS check in system that time stamps the start and end of each job.  They can, and do, concurrent services (this is a dog walking / pet sitting business).  Currently I am using a pivot table to assemble the data, and doing a MIN and MAX function to pull the beginning and end times for each employee, every day.

The problem with using the MIN and MAX function, is that there are gaps in time that are not accounted for.  I currently have to search for and manually subtract gap time from each day.  Time consuming and the potential for errors is real.  Is there a formula that would be able to look through a series of check in and check out times and total the actual number of working hours in a day?  I will give an example of hours below.

Employee Date_Check_in1 System_Check_in System_Check_out Service
CL 12/29/2019 3:34:08 PM 4:13:06 PM  5
CL 12/29/2019 12:24:28 PM 1:04:26 PM 5
CL 12/29/2019 10:04:39 AM 12:12:36 PM 1
CL 12/29/2019 9:49:33 AM 11:44:31 AM  2
CL 12/29/2019 9:44:29 AM 11:39:12 AM 1
CL 12/29/2019 9:03:31 AM 9:35:36 AM  5

The MIN /MAX pulls the hours worked as 07:09 (9:03:31 - 4:13:06), but the actual time worked is 04:18

 

Thanks in advance for any suggestion!

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
January 12, 2020 - 7:41 pm
sp_Permalink sp_Print

Hi Michael

The issue is the 3 records in yellow?

Calculating-hours-worked-purfleet1.pngImage Enlarger

and this should count as 1 visit of 2:28, rather than the 5:57?

Is there anyother data in the tabnle to identify this a one job?

Purfleet

sp_PlupAttachments Attachments
  • sp_PlupImage Calculating-hours-worked-purfleet1.png (6 KB)
Avatar
Michael Flanagan

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
January 12, 2020
sp_UserOfflineSmall Offline
3
January 13, 2020 - 2:01 am
sp_Permalink sp_Print

Purfleet, they are separate clients and separate jobs but they are done together (the dogs are all walked and exercised at the same time) the pickup and dropoff times are going to be different.  The employees get piece rate compensation and are payed per job worked, they must stay separate.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
4
January 14, 2020 - 7:58 am
sp_Permalink sp_Print

I am sure that i have seen a video where someone came up with a mad array forumla that could isolate the overlapping times and work it back (probably Mike Girvin) but i cant find it anywhere.

There must be an easier way than what i have just done as it is really complicated! But I have also tested for multiple overlapping periods and it does appear to be working.

Data MUST be sorted by column C Smallest to largest and the end time is in C8, but we might be able to work around that at some point, but my head hurts now! Also the VBA is not dynamic - ie it will only work for 6 rows of data and the header at the moment, otherwise formulas will need dragging down and c8 will need ot move.

Purfleet

PS happy to see any other suggestions, as i think i have confused myself here and over done it.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
5
January 15, 2020 - 12:20 pm
sp_Permalink sp_Print

This is my try. Time must be sorted ascending (smallest to largest).

Sunny

Avatar
Michael Flanagan

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
January 12, 2020
sp_UserOfflineSmall Offline
6
January 16, 2020 - 5:57 am
sp_Permalink sp_Print

Purfleet, thank you for breaking this down but testing this has been really problematic.  I did LOL at the file name you gave your solution, this has been a nightmare for me as well.  The VBA would need to be more nimble than this and I cannot get it to work when filtering for different data.

 

SunnyKow this tests very well, with a catch.  Real world data set for me will not always have the System_Check_out times be in the same ascending order as the System_Check_in times, so the IF/AND formula being dependent on the cell below to be a greater number throws it off.    

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
7
January 16, 2020 - 4:58 pm
sp_Permalink sp_Print

Firstly i would like to say that Sunny's method is nicer if you can get it to work, however a macro can be useful if it has to do a lot of repetitive tasks or be done multiple times - its just a simple trade off - is it worth 2 or 3 hours of coding etc to save 10 seconds once a month? Probably not, but if it was to save 30 seconds 100 times a month, then yes.

In the macro i forgot that the formula in Column G had to be an array, so it wasn't calculating correctly - that has now been fixed.

The VBA would need to be more nimble than this and I cannot get it to work when filtering for different data.

When i start with a problem like this i usually get something like the attached as a Proof of Concept, especially when i don't know the data or not 100% sure what the output should look like.

Ranges can be extended and made dynamic without too many issues

So you need to filter before calculating? I assume that there will be multiple employees in the dataset that will need filtering and then calculating? If that is the case, then again it would be quite easy to loop through all employees, filter, copy to a new sheet and then, the hard bit which we have already done, calculate the time worked.

Maybe you can upload a larger dataset so we can test?

Purfleet

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
8
January 17, 2020 - 4:23 pm
sp_Permalink sp_Print

Thanks Purfleet Embarassed

Hi Michael

Without a large range of real-world sample data and the expected result, it is extremely difficult to find a solution (if any).

Creating a solution from scratch (using only formulas and no VBA) is a hit and miss. Sometimes you are lucky and sometimes not.

Googling didn't help one bit.

Attached is my final try.

Good luck.

Sunny 

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Brian Pham, Riny van Eekelen
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.