More help on dates adding only if not week day
Posted on 2005-05-10
More on my dates problem
My start date is 1st July 2005 if i take away only mon-fri dates i should get 20th June 2005 i get 22nd June
SET_PROMISE_DATE = 7/1/2005
@SET_DEFAULT_CUTSEW_DAYS = 9
Select @CutSewDate = DATEADD(DD, -(@SET_DEFAULT_CUTSEW_DAYS), @SET_PROMISE_DATE)
but i need to only take 5 weeke days from the promise date that are week days
-- CHECK NOT A SAT OR SUNDAY
SELECT @SET_PROMISE_DAY = DATEPART(WEEKDAY, @CutSewDate)
---Sunday take away 2
if @SET_PROMISE_DAY = '1'
Select @CutSewDate = DATEADD(DD, -(@SET_DEFAULT_SUNDAY), @CutSewDate)
if @SET_PROMISE_DAY = '7'
Select @CutSewDate = DATEADD(DD, -(@SET_DEFAULT_SATURDAY), @CutSewDate)
I end up with 22 June 2005
How can i solve this .....