Hello All,
I have a confusing little problem in SQL-Server 2005 and Classic ASP. I have the following table in the database
+-----------+----------+----------+--------------+-------------------------+-------------------------+--------------+
| ProgramID | SystemID | ClientID | ProgramName | ProgramStart | ProgramEnd | ProgramHours |
+-----------+----------+----------+--------------+-------------------------+-------------------------+--------------+
| 22 | 18 | 4 | After Gym | 1900-01-01 09:00:00.000 | 1900-01-01 11:00:00.000 | 2hrs 0mins |
| 23 | 18 | 4 | Free Weights | 1900-01-01 12:00:00.000 | 1900-01-01 14:00:00.000 | 2hrs 0mins |
+-----------+----------+----------+--------------+-------------------------+-------------------------+--------------+
This basically shows a program that is assigned to a system and a client for a specific time period. What I want to do is prevent a user from entering a third program that overlaps the times already used (e.g. 10am to 11am). The creation page features drop menus for hours, minutes and am/pm for the start hour and the 3 more drop menus for the end hour. What I want to do is fire an ajax script that looks for overlapping entries when the drop menu selection changes. If it finds one it fires a js alert.
How would you detect this overlap in SQL?
Any ideas would be greatly received.
Many Thanks, Paul