Good day everyone.
I have a SQL DTS package that runs the following code and pulls the Data from an AS400 table to a SQL table. This all works rather well but i'd rather use a date function to determine the Data rather then havign to change the hard coded part on a monthly basis. The criteria looks like this:-
WHERE
(AS400Table.AS400Field BETWEEN 20100301 AND 20100331)
or
(AS400Table.AS400Field BETWEEN 20100216 and 20100315)
In SQL if I wanted to run this the WHERE clause would look like this:-
WHERE
((AS400Table.AS400Field BETWEEN dateadd(mm, datediff(mm, 0, getdate()) - 2, 0) AND SELECT dateadd(mm, datediff(mm, 0, getdate()) +1, -1))
or
((AS400Table.AS400Field BETWEEN SELECT dateadd(mm, datediff(mm, 0, getdate()) - 1, +15) AND SELECT dateadd(mm, datediff(mm, 0, getdate()) , +14))
Since the data is being pulled from AS400 the syntax will not work, can anyone assist me in automating this Data range so I can pull the correct Data from AS400 please?
Thanks in advance,
Mitch....