0

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

2
Contributors
2
Replies
5
Views
8 Years
Discussion Span
Last Post by pandiarajan.pmk
0

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?

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.