开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜