I am making an employee attendance record and I have trouble merging the raw data into time in and time out combination format.
From the given "Raw Data" Table below I need to combine the time in and time out of the employee into one row like the "Merge Time in/out" sample below.
Also consider that the employee has two shifting schedule the day shift and night shift. Take note that if the employee is in night shift schedule the time out date is different to time in date.
Day shift empid(ID001,ID002) Night shift empid(ID003)
Raw Data Table
--------------------------------------------
empid date time[in/out] in_out
--------------------------------------------
ID001 2014-08-01 7:00am IN
ID002 2014-08-01 7:01am IN
ID003 2014-08-01 8:05pm IN <--Night Shift
ID001 2014-08-01 5:00pm OUT
ID002 2014-08-01 5:01pm OUT
ID003 2014-08-02 6:01am OUT <--take note of date
Merge Time in/out Table
--------------------------------------------
empid date time_in time_out
--------------------------------------------
ID001 2014-08-01 7:00am 5:00pm
ID002 2014-08-01 7:01am 5:01pm
ID003 2014-08-01 8:05pm 6:01am