Declare
@workingDays int,
@Count int,
@totWekends int,
@startdate datetime = getdate(),
@enddate datetime = getdate()+6
set @Count=6+1;
set @workingDays= (DATEDIFF(dd, @StartDate, @EndDate) + 1) -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
-(case datepart(dw, @StartDate)+@@datefirst when 8 then 1 else 0 end)
-(case datepart(dw, @EndDate)+@@datefirst when 7 then 1 when 14 then 1 else 0 end)
set @totWekends=@Count-@workingDays
select CONVERT(VARCHAR(10),DATEADD(day,@workingDays+@totWekends,getdate()),103) AS LastDate
@workingDays int,
@Count int,
@totWekends int,
@startdate datetime = getdate(),
@enddate datetime = getdate()+6
set @Count=6+1;
set @workingDays= (DATEDIFF(dd, @StartDate, @EndDate) + 1) -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
-(case datepart(dw, @StartDate)+@@datefirst when 8 then 1 else 0 end)
-(case datepart(dw, @EndDate)+@@datefirst when 7 then 1 when 14 then 1 else 0 end)
set @totWekends=@Count-@workingDays
select CONVERT(VARCHAR(10),DATEADD(day,@workingDays+@totWekends,getdate()),103) AS LastDate
No comments:
Post a Comment