TSQL: Dates that lie between (intersect) from and to date?
Can someone give me the tsql to find also the dates that lie inside the give from and to date.
select * from empc where
DateFrom >= p_todate AND DateTo <= p_todate
What I mean is that dates in between should also be captured (I do not want to use BETWEEN syntax)
please 开发者_StackOverflowhelp
If you need to select all ranges that intersect the given range:
SELECT *
FROM empc
WHERE DateFrom <= p_todate
AND DateTo >= p_fromdate
Or you could use between:
SELECT *
FROM empc
WHERE DateFrom BETWEEN p_fromdate AND p_todate
This gives you an inclusive range.
精彩评论