Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time of First and last record in DAY.

Status
Not open for further replies.

mobbarley

IS-IT--Management
Mar 4, 2004
22
0
0
AU
Hey there.

I'm trying to do something similar to a time clock system for staff, there will be several records in a database each day for a staff member (with a unique ID), and I'd like to find the first and last record each day and calculate the time in between.

I have no idea how to go about this in a query, any help greatly appreceated.

Regards,
JohnR.
 
Try something like:

Code:
SELECT Format(Max([Time])-Min([Time]),"hh:nn") AS Elapsed, Format([Time],"dd-mm-yyyy") AS Day, YourTable.StaffMmember
FROM YourTable
GROUP BY Format([Time],"dd-mm-yyyy"), YourTable.StaffMmember;

This must return the elapsed time between the first and the last hour of each staff member every day. You can make the adjustments to fit your requirements

Greetings from Chile
 
Lupins: On each record there will be a primary key, card number, staff number (unique to each staff member), name, and a few other details. This will actually be triggered by a card swipe, releasing a door strike.
 
I think the other response (dzepeda) will give you the answer you need.
 
This code shows #error in the elapsed field, but I believe that could be because the field in the database shows date & time as: 18/03/04 01:36:37pm, and one subtract the other wont work?

Regards
John R.


 
The datetime format is not relevant.
There must be a typo in the formula you have entered.
If you can't see it yourself then post the sql here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top