marcellvries
Programmer
Hi there,
I'm designing a planning system in MS Access and currently I'm working on a query to identify events that overlap. Until now I have the following, which checks for the same employee (WerknemerID) assigned to multiple events at the same time.
The SQL statement above works, but doesn't take into account different dates. So when an employee is assigned to a task on saturday and a task on sunday, the query gives as a result that they overlap. What should I do next? I tried for hours but can't think of a solution. I'm quite a newbie when it comes to databases and queries..
For your information: WerknemerID = Employee, Btijd = Start time, Etijd = End time, PlanningID = Event ID, Bweergavedatum = Starting date, Edatum = End date.
Thank you in advance for your help!
With kind regards,
Marcell
I'm designing a planning system in MS Access and currently I'm working on a query to identify events that overlap. Until now I have the following, which checks for the same employee (WerknemerID) assigned to multiple events at the same time.
Code:
SELECT tblPlanning.PlanningID, tblPlanning.WerknemerID, tblPlanning.Bweergavedatum, tblPlanning.Edatum, tblPlanning.Btijd, tblPlanning.Etijd, tblPlanning_1.PlanningID, tblPlanning_1.WerknemerID
FROM tblPlanning, tblPlanning AS tblPlanning_1
WHERE (((Nz(([tblPlanning_1].[Btijd]>=[tblPlanning].[Etijd]) Or ([tblPlanning_1].[Etijd]<=[tblPlanning].[Btijd]) Or ([tblPlanning].[WerknemerID]<>[tblPlanning_1].[WerknemerID]) Or ([tblPlanning].[PlanningID]=[tblPlanning_1].[PlanningID]),False))=False))
ORDER BY tblPlanning.PlanningID, tblPlanning_1.PlanningID;
The SQL statement above works, but doesn't take into account different dates. So when an employee is assigned to a task on saturday and a task on sunday, the query gives as a result that they overlap. What should I do next? I tried for hours but can't think of a solution. I'm quite a newbie when it comes to databases and queries..
For your information: WerknemerID = Employee, Btijd = Start time, Etijd = End time, PlanningID = Event ID, Bweergavedatum = Starting date, Edatum = End date.
Thank you in advance for your help!
With kind regards,
Marcell