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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking a table with a date range to a table with individual dates

Status
Not open for further replies.

dubstop

Programmer
Jul 2, 2007
2
GB
I have two tables, one is data from a time and attendance system and shows when an employee clocked in and out, there is also a boolean showing if they were absent on a given dates.
My problem is that I need to only show it as an absence in the dataset if they didn't have a holiday booked for that day, the holiday booking table stores a date from and date to for a booking and I have been unable to come up with a query that will link this range and the individual dates

Clockings table has fields:
EmpNo, shiftdate, ABS
Holiday table has fields:
EmpNo, DateFrom, DateTo

I would appreciate any help on this
 
query that will link this range and the individual dates
Perhaps something like this ?
SELECT C.EmpNo, C.shiftdate, C.ABS, H.DateFrom, H.DateTo
FROM [Clockings table] AS C
INNER JOIN [Holiday table] AS H ON C.shiftdate Between H.DateFrom And H.DateTo

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you, that seems to work although it is a little slow, I shall add an index or two and see if that helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top