Select first in and Last out time for a day from multiple In and Out entries for each day

vij

Board Regular
Joined
Feb 13, 2011
Messages
215
Hi,
Require urgent help for the following:

I have multiple in and out data for number of employees coming to office for a number of days. The employees come to office in three shifts as under:


First Shift: 6:00 AM to 3:00 PM
Second Shift: 2:00 PM to 11:00 PM
Third Shift: 9:00 PM to 6:00 AM.
I want to select the first in and last out data for each employee for each day and then calculate the total number of hours spent in the office by each employee per day.
A sample data is as under:
FIRST_NAMEEMPLOYEELDAP_IDREADER_DESCLOCAL_DATELOCAL_TIME
Akshay Aggarwal41088aksaggar821-7-01 NOI:TURN 1 OUT FL72012110802:04:59
Akshay Aggarwal41088aksaggar821-8-00 NOI:TURN 2 IN FL72012110802:20:28
Akshay Aggarwal41088aksaggar821-7-01 NOI:TURN 1 OUT FL72012110803:14:26
Akshay Aggarwal41088aksaggar821-8-00 NOI:TURN 2 IN FL72012110818:31:07
Akshay Aggarwal41088aksaggar821-7-01 NOI:TURN 1 OUT FL72012110821:47:35
Akshay Aggarwal41088aksaggar821-8-00 NOI:TURN 2 IN FL72012110822:19:24
Taufique Ahmad37716taahmad821-8-00 NOI:TURN 2 IN FL72012110814:26:49
Taufique Ahmad37716taahmad821-7-01 NOI:TURN 1 OUT FL72012110822:15:11
Taufique Ahmad37716taahmad821-8-00 NOI:TURN 2 IN FL72012110822:39:50
Taufique Ahmad37716taahmad821-7-01 NOI:TURN 1 OUT FL72012110823:25:27
Akshay Aggarwal41088aksaggar821-8-01 NOI:TURN 2 OUT FL72012110901:59:25
Akshay Aggarwal41088aksaggar821-8-00 NOI:TURN 2 IN FL72012110902:17:23
Akshay Aggarwal41088aksaggar821-7-01 NOI:TURN 1 OUT FL72012110903:19:10
Akshay Aggarwal41088aksaggar821-7-00 NOI:TURN 1 IN FL72012110918:09:38
Taufique Ahmad37716taahmad821-8-00 NOI:TURN 2 IN FL72012110914:17:49
Taufique Ahmad37716taahmad821-7-01 NOI:TURN 1 OUT FL72012110923:25:33

<tbody>
</tbody>

<tbody>
</tbody>

The data is required in the following format
DateTotal HoursAkshay AggarwalTaufique Ahmadl
In08-Nov-12hh:mm:ss
Out08-Nov-12
hh:mm:ss

<tbody>
</tbody>
Total Hours
hh:mm:ss (Out - In)

<tbody>
</tbody>
In09-Nov-12
Out09-Nov-12
Total Hours
In10-Nov-12
Out10-Nov-12
Total Hours

<tbody>
</tbody>

Thanks in advance,
Vij
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
As I mentioned in my post, there are three shifts in which the employees come for duty. On this particular day Akshay would have reported for the shift accordingly or would have got late/ reported early for duty.
 
Upvote 0
Also the In/ Out status is taken from READER_DESC "821-7-01 NOI:TURN 1 OUT FL7", "821-8-00 NOI:TURN 2 IN FL7"
 
Upvote 0
If your first table is in the range A1:F17 on Sheet1 and your second table is in the range A1:E10 on Sheet2, for the first in in D2 on Sheet2:

=MIN(IF(Sheet1!$A$2:$A$17=D$1,IF(ISNUMBER(SEARCH(" "&$A2&" ",Sheet1!$D$2:$D$17)),IF(Sheet1!$E$2:$E$17=$B2,(Sheet1!$F$2:$F$17+(Sheet1!$F$2:$F$17<"06:00"+0))))))

confirmed with Ctrl+Shift+Enter. For the last out in D3:

=MAX(IF(Sheet1!$A$2:$A$17=D$1,IF(ISNUMBER(SEARCH(" "&$A3&" ",Sheet1!$D$2:$D$17)),IF((Sheet1!$E$2:$E$17-(Sheet1!$F$2:$F$17<"06:00"+0))=$B3,(Sheet1!$F$2:$F$17+(Sheet1!$F$2:$F$17<"06:00"+0))))))

confirmed with Ctrl+Shift+Enter.

Copy the formulas down and across.
 
Upvote 0
Did you press Ctrl+Shift+Enter not just Enter? if entered correctly Excel will surround the formula with curly braces {}. Results using your data:


Excel 2003
ABCDE
1DateTotal HoursAkshay AggarwalTaufique Ahmad
2In08-Nov-12hh:mm:ss18:31:0714:26:49
3Out08-Nov-12hh:mm:ss03:19:1023:25:27
4Total Hourshh:mm:ss (Out - In)
5In09-Nov-1218:09:3814:17:49
6Out09-Nov-1200:00:0023:25:33
Sheet2
 
Upvote 0

Forum statistics

Threads
1,215,856
Messages
6,127,365
Members
449,381
Latest member
Aircuart

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top