I have a report that currently shows the times a person checked in and then out of a class. My user wants a calculation showing the total time in class. I've looked for a way and can't seem to find one. Mooo...
This isn't working. I have only one time field. For each set of records, there are two, an in and out, I need to calculate the total time. The original design and function of this database doesn't allow for a second field to hold the Checkout time. Does this mean that I cannot do the calculations? Mooo...
Well, you might be able to accomplish it but it will be more complex. Post a sample of what your field looks like and tell us what the datatype for the field is (in the Table).
I'm smacking myself in the head. I pulled the properties of the table and for the first time noticed that the time field is formatted as text. No wonder I can't do calculations.
I cannot redesign the tables. Any ideas on how I could work around this? Mooo...
OK that's fine but what are you trying to calculate the difference between? I reread you post. Your said, "for each set of records". What do you mean by that. It sounds like you have the In time in one record and the Out time in another record. What we are going to try and do is use the CDate() function to convert the value from text to a Date/Time value that can be calculated but I need to know exactly how the records are set up so I can see exactly how to get at the data.
OK. Each record in the table has 6 fields. One of the fields is 'Swipetime'. This records the time a person swipes a card through a reader. The first time the card is swiped the system marks a yes/no field for 'Checked in'. the second time the card is swiped it unmarks the 'cheked in' field. We wanted a report that shows the people checked in and out on any given day which we have. What we want to add is a field that shows the length of time that each person was checked in. There are two or four records for each person on each day. Unfortunately there is not a field for in and a field for out.
I sure appreciate your help. Mooo...
OK, here's what I have for you. qrySwipe1 is used to convert the text datatype to date. I only have three fields but you can add all 6 of your fields to this query.
SELECT tblSwipe.EmpID, CDate([SwipeTime]) AS Swipe_Time, tblSwipe.[In/Out]
FROM tblSwipe
ORDER BY tblSwipe.EmpID, CDate([SwipeTime]);
qrySwipe2 takes the records and arranges them in such a way as to be able to do the calculations. Notice that this query only has the fields we need to isolate specific records and do the calculations. Depending on what other fields you have, some of them may not be available to this query.
SELECT qrySwipe1.EmpID, qrySwipe1.Swipe_Time, Min(qrySwipe1_1.Swipe_Time) AS MinOfSwipe_Time, Format([qrySwipe1].[Swipe_Time]-1-[MinOfSwipe_Time],"Short Time" AS Expr1
FROM qrySwipe1, qrySwipe1 AS qrySwipe1_1
WHERE (((qrySwipe1.[In/Out])=-1) AND ((qrySwipe1_1.Swipe_Time)>[qrySwipe1].[Swipe_Time]) AND ((qrySwipe1_1.[In/Out])=0))
GROUP BY qrySwipe1.EmpID, qrySwipe1.Swipe_Time;
Thats great, I have never reformatted a field like that. Of course now I'm getting a syntax error. Nothing can be easy this week. I've put it in my system just like you posted it. And I see nothing wrong with it. So I'm waiting for new eyes to look at it for me.
I appreciate your help and will post again if there are anymore problems. Mooo...
Found the syntax error, I missed a [ .
Works great now.
Your the best. I love this forum. Always nice to learn new things that make my job easier. Mooo...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.