Board index » delphi » more of a SQL question then a ADO question

more of a SQL question then a ADO question

I have a table that holds appointments.  I have the fields
StartFrom,EndPeriod (TDateTime) and RmID (foreign field to the table
tblResources).  Does anyone know the SQL or procedure if I have two
TDateTime values (start and end periods) for a ResourceID and I want to
check and see if there's a conflicting time?
 

Re:more of a SQL question then a ADO question


Quote
>I have a table that holds appointments.  I have the fields
>StartFrom,EndPeriod (TDateTime) and RmID (foreign field to the table
>tblResources).  Does anyone know the SQL or procedure if I have two
>TDateTime values (start and end periods) for a ResourceID and I want to
>check and see if there's a conflicting time?

Try something like this.

Select D.rmId from Tbl D
Join Tbl D2 on (D.Startfrom Between D2.Startfrom and D2.EndPeriod)
or (D.EndFrom Between D2.Startfrom and D2.EndPeriod)
where D.Rmid <> D2.Rmid
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads