tags:

views:

26

answers:

2

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 help

+1  A: 

If you need to select all ranges that intersect the given range:

SELECT  *
FROM    empc
WHERE   DateFrom <= p_todate
        AND DateTo >= p_fromdate
Quassnoi
A: 

Or you could use between:

SELECT  *
FROM    empc
WHERE   DateFrom BETWEEN p_fromdate AND p_todate

This gives you an inclusive range.

Paddy
I don't want to use between
abmv
Downvote's a little harsh, considering I added this answer before the note about not wanting between...
Paddy