Hi all
I have been making a T & A Database with data coming direct from the time clocks. Trouble is it puts each clockin on a seperate row.
I have been using the code I found on this forum posted by Jon K
This works great at putting clocks in the right order. The trouble I have is that it becomes really slow when using lots of data, normally there are 4 clockins per person per day, so on a company that has 70 exployees, thats 280 clockins per day. This really really slows the query down. Is there a way that I can speed things up??
I have been making a T & A Database with data coming direct from the time clocks. Trouble is it puts each clockin on a seperate row.
I have been using the code I found on this forum posted by Jon K
Code:
Assuming DATE, TIME are date/time fields in table tblPunchCard, try these two queries (type/paste in the SQL View of each new query):
qryOne:-
SELECT [EMP ID], [DATE], [TIME],
(Select count(*) from [tblPunchCard] where [EMP ID] = a.[EMP ID] and [Date]+[Time] <= a.[Date]+a.[Time]) AS Num,
iif(Num mod 2 =1, "In" ,"Out") AS InOut,
iif(InOut="In", Num, Num-1) AS Pair
FROM [tblPunchCard] AS a;
qryTwo:-
SELECT [EMP ID], Min([Date]) AS [Clock-In Date],
format(Min([Date]+[Time]), 'Short time') AS [Clock-in Time],
iif(Max([Date]+[Time]) <> Min([Date]+[Time]), Max([Date]), Null) AS [Clock-out Date],
iif(Max([Date]+[Time])<>Min([Date]+[Time]), format(Max([Date]+[Time]) ,'Short Time'), Null) AS [Clock-out Time]
FROM qryOne
GROUP BY [EMP ID], Pair;
Run the second query.
(As clock-in date and clock-out date are different in the sample data, I have included [Clock-out Date] in the query result. You can delete it if you want to.)
__________________
Access 2003, WinXP
This works great at putting clocks in the right order. The trouble I have is that it becomes really slow when using lots of data, normally there are 4 clockins per person per day, so on a company that has 70 exployees, thats 280 clockins per day. This really really slows the query down. Is there a way that I can speed things up??