michaela18
Technical User
I have the following
declare @ActualDate datetime
declare @importdate datetime
declare @DateDiff int
set @DateDiff=datediff(day,@StartDate,@EndDate)
DECLARE @rtDayofWeek VARCHAR(10)
set @DateDiff=@DateDiff+1
while @DateDiff>0
begin
set @ActualDate=@StartDate
set @rtDayofWeek =DATEPART(weekday,@StartDate)
if @rtDayofWeek>=2 and @rtDayofWeek<=5 --Monday to thursday
begin
set @StartDate=dateadd(day,1,@StartDate)
set @importdate=@StartDate
set @DateDiff=@DateDiff-1
insert into @TempOBRMasterData select *,OBR_10_bundle+OBR_Blackberry as 'Total' from Fn_GetOBRMasterDataByimportdate(@importdate,@ActualDate)
end
else
begin
if @rtDayofWeek=6 --Frieday
begin
set @importdate=dateadd(day,3,@StartDate)
insert into @TempOBRMasterData select *,OBR_10_bundle+OBR_Blackberry as 'Total' from Fn_GetOBRMasterDataByimportdateFriday(@importdate,@ActualDate)
set @StartDate=dateadd(day,1,@StartDate)
set @DateDiff=@DateDif
I am having trouble with the dates. The way I run the procedure is :
exec procedure 'date beginning','date ending'
How can I set my procedure for friday where day of week = 6 so that
set @StartDate=dateadd(day,0,@StartDate)
instead of dateadd(day,1,@startdate) because when I change it to 0 i get errors.