Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to check time conflict in time table and if no time conflict then insert a new appointment ?
I want to book a room if there is no time conflict with exist none empty room.
So first how to write acode for checking time conflict in these two records at least and it returns 0 , then insert a new record if there is not time conflict.

i tried the following but it gives me these records below, also i tried count(*) and the result was 2 which is not correct, it supposed to be 0 .

i want to check time conflict depending on (day name) and both (start_time), (End_time)

SQL
SELECT t2.* FROM
Room_Information  t1
 INNER JOIN
 Room_Information  t2
 on
     (t1.Start_Time   < t2.End_Time
       and
    t1.End_Time  > t2.Start_Time) and (t1.Day_Name=t2.Day_Name) and t1.Schedule_ID = t2.Schedule_ID and t1.Term_ID=118 and t1.room_id=140 ;


and this is my table

Term_Desc| Ac_Course_Code| Day_Name| Time_Desc| End_Time| Room_No| Section_Name | Room_ID | Term_ID | Schedule_ID
Summer I 2001 | COS 25 | Sunday | 10.30 | 12.00 | 7001-M3017 | D1 | 140 | 150 | 18915
Summer I 2001 | COS 25 | Sunday | 14.00 | 15.00 | 7001-M3017 | D2 | 140 | 150 | 18928
Posted
Updated 9-Jul-14 6:09am
v2
Comments
progahmed 9-Jul-14 5:57am    
i did but i did not get 0 and also no time conflict

Change it to return the COUNT instead of the items, and only do the insert if the value is zero.
 
Share this answer
 
i tried your solution but not working
i update my question with my table and result please check
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900