This is not my function.Its taken from above answer of Uma Shankar Patel.
But It have a small problem.This problem occurence when at the last @found =0
Rectified problem is below
ALTER FUNCTION [dbo].[WeekdaysInInterval]
( @StartDate SMALLDATETIME, @EndDate SMALLDATETIME, @day_of_week VARCHAR(9) )
RETURNS INT
AS
BEGIN
DECLARE @found INT, @num INT
SET @found = 0
WHILE @found = 0 AND (@StartDate < @EndDate)
BEGIN
IF DATENAME(weekday,@StartDate) = @day_of_week
BEGIN SET @found = 1 END
ELSE
SET @StartDate = DATEADD(day,1,@StartDate)
END
SET @num = (DATEDIFF(day,@StartDate, @EndDate) / 7) + @found
RETURN @num
END