T-SQL to add 7 days to ship date

  • Hello All,

    A quick question to all regarding my query. Below statement adds 7 days to the shipment date if we miss the ship date. For example something that was suppose to ship on 07/24/2014 did not get shipped for some reason; following query adds 7 days i.e 07/31/2014 to the ship date. The only problem is the 'Test Ship' column adds 7 days to the shipment days only on Sundays if we miss the shipment date. I mean for the jobs that had scheduled ship date 07/24/2014, and we missed the jobs to ship on the 07/24/2014, below column 'Test Ship' updates next schedule ship day 07/31/2014 only on SUNDAY. For example say J012345 job did not get shipped on 07/24/2014, 'Test Ship' column will update the date tomorrow i.e 07/27/2014 (Sunday) instead of updating it on FRIDAY 07/25/2014. Am I missing anything here? How can I get 'Test Ship' to update the date on FRIDAY instead of SUNDAY? I would appreciate your help on this. Thanks.

    'Test Ship' = Case when j.JobStatus <>'S'

    and Cast(x.ExpectedDate as Date) < DATEADD(wk, DATEDIFF(wk,3,cast (GETDATE() as date)), 3)

    then Dateadd(day,4,cast (DATEADD(week, DATEDIFF(week,0,GETDATE()),-1) as date))

    when j.JobStatus ='S' then Cast(j.LastShippedDate as DATE)

    else Cast(x.ExpectedDate as Date) END

  • Duplicate post, answers in the other thread please!

    😎

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply