Declare @counter int = 0, @strt date, @end date Begin set @strt=(Select Distinct StartDate From SchoolTerms where EmisCode ='500226884' AND CurrentYear='2009' AND Quater='Term1') Set @end=(Select Distinct EndDate From SchoolTerms where EmisCode ='500226884' AND CurrentYear='2009' AND Quater='Term1') while (@strt<@end) if DATEPART(weekday,@strt)<>7 or DATEPART(weekday,@strt)<> 1 set @counter+=1 set @strt=@strt-1 print @strt print @end print @counter End;
Msg 206, Level 16, State 2, Line 19 Operand type clash: date is incompatible with int
set @strt=@strt-1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)