I need a query returns all rows between two dates or rows that overlap the date range in any way.
Answer
SELECT *
FROM MyTable
WHERE
(
/*When the start date is before the range but the end date falls in or after the range*/
(StartDate < @StartDate AND EndDate >= @StartDate)
/*When the StartDate falls in the range. The end date can be in or out of the range*/
OR (StartDate >= @StartDate AND StartDate < @EndDate)
)
Hope this helps. All Answers provided are subject to our standard Answers Disclaimer.




Comments