Each appointment saved to the database is saved to the following fields,
StartTime and FinishTime (i.e. the time the appointment starts and the time the appointment finishes)
I am trying to write a SQL query to find any appointments within a given time.
For example,
i have saved an appointment in the database with a starttime of 09:00 and a finishtime of 10:00.
A user then wants to add an appointment for 09:30 to 10:30, so i would like to run a query, and in this example it would pull up from the database the appointment 09:00 to 10:00
I just can't seem to get the query right to perform the search.
I am using SQL Server 2008, i have tried the following query, but it doesn't return any results
Question
REM2000
Hi All
I am writing an Appointment application,
Each appointment saved to the database is saved to the following fields,
StartTime and FinishTime (i.e. the time the appointment starts and the time the appointment finishes)
I am trying to write a SQL query to find any appointments within a given time.
For example,
i have saved an appointment in the database with a starttime of 09:00 and a finishtime of 10:00.
A user then wants to add an appointment for 09:30 to 10:30, so i would like to run a query, and in this example it would pull up from the database the appointment 09:00 to 10:00
I just can't seem to get the query right to perform the search.
I am using SQL Server 2008, i have tried the following query, but it doesn't return any results
use BookingManagerR1
select booking.title, booking.starttime, booking.finishtime
from Booking
where (starttime >= '09:30') and (finishtime <= '10:30')
I just can't seem to wrap my head around fixing this, any help would be really appreciated.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts