I give two parameter like year & period.
For example year = 2009 &
period=3
Result : 22 working days in this month
Plz help me.

Are period and month the same thing? What do you define as a working day? Are you wanting to only use MySQL to do this or are you combining with another programming language such as PHP?

This is i have tried first find number of week days in a month. But I need to subtract the saturdays and sundays from that result theweeks

DECLARE	@theYear SMALLINT
DECLARE	@theMonth SMALLINT
SET	@theYear = ?Year?      /* My year parameter
SET @theMonth=?Period?   /* My period or month parameter


SELECT	theMonth,
	(theLast - theFirst )  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,
weekdayDiff = datediff(dy,@aDate,@bDate) - (datediff(dy,@aDate,@bDate)/7*2 + 
			case when datepart(dw,@aDate)=1 and datediff(dy,@aDate,@bDate)%7<6 then 1
			
	FROM	OAS_docline
	WHERE	 @theMonth < 12
	) AS d

Result:

Year =2008
period= 2

theMonth theweek

2 4

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.