I couldn't find anything that was already built-in to SQL but if you're using SQL2000 you can write a user-defined function to do this. This is my first attempt at such a thing and its late in the day so I apologize if its not the brilliant answer you were hoping for.
Try this:
create function fn_calc_weekday (@date1 smalldatetime, @date2 smalldatetime)
returns int
as
begin
declare @weekday table
([date] smalldatetime,
day_number tinyint)
declare @num_weekdays int
while @date1 <= @date2
begin
insert into @weekday
([date],
day_number)
values (@date1,
datepart(dw,@date1))
select @date1 = dateadd(d,1,@date1)
end
select @num_weekdays =
(select count(day_number)
from @weekday
where day_number in (2,3,4,5,6))
return (@num_weekdays)
end
Then call the function passing the dates in a parameter like this:
select dbo.fn_calc_weekday('01/01/01','01/08/01')
This function can also be called from stored procedures and other queries just like any other SQL function. Let me know how it goes!