简体   繁体   中英

Calculate working hours in Excel based on in out times

I would like to automatically calculate the working times of my employees based on the time they entered and left the company. I have a badge system on the door that exports HTML files for every employee based on badge code. So I figured out on how to automatically import all the tables from the html files into Excel so they can be processed more easily.

My main problem is that in and out are in the same column in the Excel file. in following format :

Date Hour Action
04-01-2018 07:15 IN

04-01-2018 16:05 OUT

05-01-2018 6:52 IN

05-01-2018 16:05 OUT

Sometimes they also go out during lunch break and then I have situations like this:

06-01-2018 07:13 IN

06-01-2018 12:05 OUT

06-01-2018 12:27 IN

06-01-2018 16:06 OUT

Since in and out is in the same column I can't just do 16:06 - 07:13 so I would like to find a way to look at the dates in the first column, if the date is the same then look at the third column and select the OUT with the latest time and retract that from the IN with the earliest time.

If anyone could help me with that, that would be great.

Two answers

(1) If you want the time minus the lunch break, mathematically it's

out1 - in1 + out2 - in2 +...

which can be re-arranged to give

out1 + out2 + ... - (in1 + in2 + ...)

So you can do it with a couple of SUMIFS

=SUMIFS(B1:B10,A1:A10,A1,C1:C10,"out")-SUMIFS(B1:B10,A1:A10,A1,C1:C10,"in")

(2) If you want the time from first arriving to going home, you can get it by

=AGGREGATE(14,6,B1:B10/((A1:A10=A1)*(C1:C10="out")),1)-
AGGREGATE(15,6,B1:B10/((A1:A10=A1)*(C1:C10="in")),1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM