I have a table with below columns
@StartTime TIME(0),
@EndTime TIME(0)
When I add a new timeslot, I need to check and get list of any overlapping slots exists. New slot start time can be existing time slot end time.
SELECT *
FROM dbo.TimeSettingDetail cdsd
WHERE
AND
(
(@StartTime between cdsd.StartTime and dateadd(MINUTE, 1, cdsd.EndTime))
or
(@EndTime between dateadd(MINUTE, 1, cdsd.StartTime) and cdsd.EndTime)
)
This is not working as expected in below scenario.
If a time slot exists for 7 AM to 8 AM, when trying to add a new timeslot from 6 AM to 9 AM.