• bmg002 - Tuesday, October 17, 2017 10:51 AM

    This may not be the most efficient method, but could you implement something like this:
    DECLARE @date DATE = '2017-04-17';

    SELECT
        CASE WHEN DATEPART(MONTH, @date) = DATEPART(MONTH, GETDATE())
                 OR DATEPART(MONTH, DATEADD(MONTH, 6, @date)) = DATEPART(
                                                                             MONTH ,
                                                                             GETDATE()
                                                                         ) THEN
                 'yes'
             ELSE 'no'
        END AS [6monthinc];

    so your where caluse would have at the end something like:
    AND CASE WHEN DATEPART(MONTH, StartDate) = DATEPART(MONTH, GETDATE())
                 OR DATEPART(MONTH, DATEADD(MONTH, 6, StartDate )) = DATEPART(
                                                                             MONTH ,
                                                                             GETDATE()
                                                                         ) THEN
                 1
             ELSE 0 END = 1

    The only problem I see with your existing code is that if you subtract 3 days from Tuesday, you get Saturday.  

    This may not be the most efficient way of doing it but I think it solves your problem, no?

    EDIT - the AND section should have used StartDate not @date.

    It's absolutely fine to select rows where the StartDate is Saturday. The problem is with StartDates on Wednesday or Thursday as this job won't be running on Saturday and Sunday to pick them up.
    Thanks for replying, I think I can get something working based on the replies I have received so far.