one method:-DECLARE @EndDate datetime,@StartDate datetimeSELECT @EndDate='25 Oct 2007',@StartDate='25 Oct 2008'--example datesSELECT DATEDIFF(dd,MIN(Date),@StartDate)- SUM(Counter)FROM(SELECT DATEADD(dd,-1*number,@StartDate) AS Date,CASE WHEN DATEPART(dw,DATEADD(dd,-1*number,@StartDate)) IN (1,7) THEN 1 ELSE 0 END AS CounterFROM master..spt_valueswhere type='p'and DATEADD(dd,-1*number,@StartDate)>@EndDate)t
you can use this for dates at a maximum difference of 5 years