I use 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 returns records where ACTISSUEDATE is not null and ACTSTARTDATE is not between the beginning of the year and today. @Year_Filter_Start should be earlier this year, @Year_Filter_End should be today.
For instance:
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?
source
share