Query to Run bi-monthly pulling transactions dated 1-14 and 15-EOM
Posted on 2006-07-13
I have a dts package that is currently scheduled to execute every other Tuesday. I pull in the data from the previous 2 weeks (ending sunday) using the following on my where statement:
(DATEDIFF(week, TranDate, GETDATE()) IN (1, 2))
I have now been requested to change this to run on the 1st and 15th of each month.
The run on the 1st should pull data from the 15 to the end of the previous month.
The run on the 15th should pull data from the 1st to the 14th of the current month.
Can I use a CASE statement in my selection criteria to pull based upon the run date? I'd like it to be a little more generic than hardcoding the 1st and 15th. For instance, if it had to be ran on the 16th, I'd still like it to pull the data for the 1st - 14th.