CREATE FUNCTION [dbo].[udsf_GetWeekEndCount]
(
-- Add the parameters for the function here
@StartDate Datetime, @EndDate Datetime
)
RETURNS INT
AS
BEGIN

DECLARE @HolidayCnt as Int
SET @HolidayCnt = 0

WHILE(@StartDate <= @EndDate)

BEGIN

IF(DateName(dw, @StartDate) = 'Saturday' OR DateName(dw, @StartDate) = 'Sunday')
SET @HolidayCnt = @HolidayCnt + 1
SET @StartDate = Dateadd("d", 1, @StartDate)

END

RETURN @HolidayCnt END
GO

It is called like "Select dbo.udsf_GetWeekEndCount('7/1/2009', '7/11/2009')
The result is 3