Hi,
I have the following problem:
I have a table of users and a table of appointments that references
these users and has start and end times.
I want to select those users that have appointments at, or bridging,
the given time.
As a starter I've tried to do the following:
DECLARE @Date DATETIME
SET @Date = '19 March 2004 14:00:00' -- the appointment time we want
to find an
-- an available user for
SELECT UserId
FROM Appointments
WHERE CONVERT(char(30 ), ApptTime, 100) = CONVERT(char(30 ), @Date, 100)
OR CONVERT(char(30 ), @Date, 100)
BETWEEN CONVERT(char(30 ), ApptTime, 100)
AND CONVERT(char(30 ), ApptEndTime, 100)
)
Which I thought should give me all the users that have an appointment
at this time, or appointments that bridge the given time.
However, the BETWEEN part of this select doesn't seem to work, as I
have one user who has an appointment from 9 in the morning to 3 in the
afternoon and their ID is not returned in this select.
Any help gratefully appreciated.
Thanks
Jane
I have the following problem:
I have a table of users and a table of appointments that references
these users and has start and end times.
I want to select those users that have appointments at, or bridging,
the given time.
As a starter I've tried to do the following:
DECLARE @Date DATETIME
SET @Date = '19 March 2004 14:00:00' -- the appointment time we want
to find an
-- an available user for
SELECT UserId
FROM Appointments
WHERE CONVERT(char(30 ), ApptTime, 100) = CONVERT(char(30 ), @Date, 100)
OR CONVERT(char(30 ), @Date, 100)
BETWEEN CONVERT(char(30 ), ApptTime, 100)
AND CONVERT(char(30 ), ApptEndTime, 100)
)
Which I thought should give me all the users that have an appointment
at this time, or appointments that bridge the given time.
However, the BETWEEN part of this select doesn't seem to work, as I
have one user who has an appointment from 9 in the morning to 3 in the
afternoon and their ID is not returned in this select.
Any help gratefully appreciated.
Thanks
Jane
Comment