Working days
665268Mar 25 2009 — edited Mar 25 2009I am calculate working days. So i first find number of weeks in a month. This my query.
DECLARE @theYear SMALLINT
DECLARE @theMonth SMALLINT
SET @theYear = ?Year? //*Year parameter
SET @theMonth=?Period? //*month parameter
SELECT theMonth,
(theLast - theFirst + 1) * 5 AS theWeeks
FROM (
SELECT @theMonth AS theMonth,
datediff(day,-1,dateadd(month,((@theyear-1900)*12)+@theMonth,0))/7 AS theFirst,
datediff(day,-1,dateadd(month,((@theyear-1900)*12)+@theMonth,30))/7 AS theLast
FROM OAS_docline
WHERE @theMonth < 12
) AS d
Please help me how to calculate working days in a month.