AND ( (@ttStart Between begintime And endtime) OR (@ttEnd Between begintime And endtime) )>I have the following stored procedure that I tried to determine if a scheduled event overlaps another scheduled event for the same surgeon. It will return a result set (conflict exists) if the the endtime or begintime are between another scheduled event. BUT it won't return a conflict (and I want it to) if the case is between the begin and endtime of another case.
>CREATE PROCEDURE ct_Con_SurgeonCase >@tiMeetID int, >@tiDocID int, >@ttStart datetime, >@ttEnd datetime > >as > > >SELECT < some fields > < snip > >FROM dbo.meetings INNER JOIN > dbo.meetproc ON dbo.meetings.meetingnumber = dbo.meetproc.meetingnumber >WHERE dbo.meetings.meetingnumber != @tiMeetID >AND dbo.meetproc.coPerID = @tiDocID >AND (begintime BETWEEN @ttStart AND @ttend OR endtime BETWEEN @ttStart and @ttEnd) >GO >