I'm using this
DECLARE @Year_Filter_Start AS DATETIME
SET @Year_Filter_Start = DATEADD( dd, -1, DATEADD( yy, DATEDIFF( yy, 0, GetDate() ), 0 ) )
DECLARE @Year_Filter_End AS DATETIME
SET @Year_Filter_End = GetDate()
INSERT INTO TABLE
( blah )
SELECT blah
FROM OTHER_TABLE
WHERE ACTISSUEDATE IS NULL
OR ACTSTARTDATE BETWEEN @Year_Filter_Start AND @Year_Filter_End
and it's returning records where ACTISSUEDATE is not null and ACTSTARTDATE is not between the year start and today. @Year_Filter_Start is supposed to be the beginning of this year, @Year_Filter_End is supposed to be today.
For example:
A record where ACTSTARTDATE is 2010-08-02 and ACTISSUEDATE is 2011-03-15
Or where ACTSTARTDATE is 2009-05-18 and ACTISSUEDATE is 2009-09-06
Is there something wrong with this statement?
Try the following, you need a few more parentheses I think:
WHERE ((ACTISSUEDATE IS NULL)
OR (ACTSTARTDATE BETWEEN @Year_Filter_Start AND @Year_Filter_End))
The engine sees this as two statements the way you have it. You need to make it one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With