开发者

TSQL: Dates that lie between (intersect) from and to date?

开发者 https://www.devze.com 2022-12-30 11:57 出处:网络
Can someone give me the tsql to find also the dates that lie inside the give from and to date. select * from empc where

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

精彩评论

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

关注公众号