we are making a date range picker for employee vacations
for example i will user January 2016 as an example and our system goes from sunday through saturday
if an employee takes a vacation from January 14-20 they should be in the date range 10-16 and also 17-23
I just cant think of how to write an sql query that will limit it to those 2 dates.
What i have is:
DECLARE @WeekRangeStart DATETIME ='2016/01/10';
DECLARE @WeekRangeEnd DATETIME = '2016/01/16';
SELECT [ID],
[EmpName],
[EmpType]
FROM Vacations
WHERE VacationStartDate >= @WeekRangeStart OR VacationEndDate >= @WeekRangeStart
--OUTPUT
--ALL DAYS BEFORE THIS WOULD BE TRUE...
--1/14/2016 >= 1/10/2016 TRUE
--1/20/2016 >= 1/10/2016 TRUE
-- NEXT WEEK
--1/14/2016 >= 1/17/2016 FALSE
--1/20/2016 >= 1/17/2016 TRUE
-- NEXT WEEK
--1/14/2016 >= 1/24/2016 FALSE
--1/20/2016 >= 1/24/2016 FALSE
--ALL DAYS AFTER THIS DAY WOULD BE FALSE...
but this only works for for a things that have passed, But if i were to book a day in march i would always show on the schedules because my startdate would greater than today. How should i go about limiting it to that range only?