Thanks to Jeff Moden for this function, which I found at http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/:
SELECT
(DATEDIFF(dd, @StartDate, @EndDate) + 1)
-(DATEDIFF(wk, @StartDate, @EndDate) * 2)
-(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)
-(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)
No comments:
Post a Comment