I've inherited a clocking in database which enables staff to register an 'In' and 'Out' event based on their fingerprint stamp.
The table has the following fields and creates a record for each fingerprint stamp, so I've got In's and Out's on separate records.
ClockID - Employee number
Name - Persons full name
CheckType - This is either I or O for 'In' or 'Out'
CheckTime - This is in the format dd/mm/yyyy hh:mm
I've been asked to create a report for excel that pulls in the employee's In and Out times for each day so payroll can be processed at the end of the week
The problem is that if someone registers more than 1 In or Out, I don't know how to just use the first stamp In and the last stamp Out to calculate the difference. (Or better still calculate between multiple times throughout the day)
I've tried various things like splitting the date and time into their own columns in the query, but the DateDiff function doesn't work because there is only 1 date/time per record, the other date/time is on a separate record.
This is my query so far...
However, it puts the In and Out on 2 separate lines and I can't work out how to calculate the daily hours (see attached spreadsheet)
Any help in being able to calculate the daily hours worked would be much appreciated
The table has the following fields and creates a record for each fingerprint stamp, so I've got In's and Out's on separate records.
ClockID - Employee number
Name - Persons full name
CheckType - This is either I or O for 'In' or 'Out'
CheckTime - This is in the format dd/mm/yyyy hh:mm
I've been asked to create a report for excel that pulls in the employee's In and Out times for each day so payroll can be processed at the end of the week
The problem is that if someone registers more than 1 In or Out, I don't know how to just use the first stamp In and the last stamp Out to calculate the difference. (Or better still calculate between multiple times throughout the day)
I've tried various things like splitting the date and time into their own columns in the query, but the DateDiff function doesn't work because there is only 1 date/time per record, the other date/time is on a separate record.
This is my query so far...
Code:
SELECT USERINFO.Badgenumber, USERINFO.Name, CHECKINOUT.CHECKTYPE, First(IIf([CHECKTYPE]="I",[ChkTime1],"")) AS CLStart, Last(IIf([CHECKTYPE]="O",[ChkTime1],"")) AS CLEnd, DateValue([CHECKTIME]) AS ChkDate, TimeValue([CHECKTIME]) AS ChkTime1
FROM CHECKINOUT LEFT JOIN USERINFO ON CHECKINOUT.USERID = USERINFO.USERID
GROUP BY USERINFO.Badgenumber, USERINFO.Name, CHECKINOUT.CHECKTYPE, DateValue([CHECKTIME]), TimeValue([CHECKTIME]);
However, it puts the In and Out on 2 separate lines and I can't work out how to calculate the daily hours (see attached spreadsheet)
Any help in being able to calculate the daily hours worked would be much appreciated