I am trying to calculate a formula for how long an employee is in a building based upon data from our security system for building entry/exit. The data generally looks like this:
Date In/Out
4/3/2017 5:41 AM In
4/3/2017 5:34 PM Out
But there are exceptions, multiple punches in a day, multiple "In" punches in a row etc. My main concern is the first and last punches of the day. I know how to subtract the two, but I need to know how to use a formula that will return the first entry, and the last entry, to be subtracted from one another.
My best attempt so far turned the day into an integer, then waited till the adjacent days were not equal to return a value.
i.e.
=IF(DAY(A8)<>DAY(A9),1,0)
I could do a huge if statement that says "If B8=B7=B6=B5.." then take the bottom minus the top (A8-AX) but that would take a lot and still not handle every exception. There has to be a function that returns the number of values (like a countif?) then calculates a column of that height and returns the difference of only two cells within that value (top and bottom)
Here It is the formula which i have used is =IF(B2:B9=B2,MAX(A2:A9)-MIN(A2:A9)) , it checks for the employee id in this case it is 1 and find out the last out and 1st in time and Calculates the total Working hour of your Employee
Hope this helps
The date and time in excel are saved as a numeric floating point values. You can use value() to see it's value. date are its integer and the floating point values are the time.
Using that as basis, assuming 1 employee, here is my sample data.
And the formulas :
select D1:L1 and drag it until L9. It's labels :
by the way for clarity, set column D,E,K format as dd/mm/yyyy and column L as hh:mm:ss .
Hope that helps. (: