For this i have created a function in which you have to pass two date from to to date
and it will calculate the no.of mondays in the given two dates
Create Function Monday(@dt1 datetime,@dt2 datetime) returns int
as
Begin
Declare @cnt int,@dt as datetime
set @cnt=0
if @dt1 < @dt2
Begin
set @dt=@dt1
Begin
if Datepart(dw,@dt)=1
Begin
set @cnt=@cnt+1
set @dt=dateadd(dd,1,@dt)
End
set @dt=dateadd(dd,1,@dt)
End
End
if @cnt=0
Begin
return 0
End
Return @cnt
End
select dbo.Monday('2005-01-01','2005-02-28')
ok bye??