Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate working days
Message
 
 
To
05/02/2002 21:41:14
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00615849
Message ID:
00615853
Views:
15
>In my program I need to cacluate the working days of every month. Does Visual Foxpro provide this function. my region is Hong Kong. please give me some reference. thanks a lot!

Here is another way to calculate the number of working days in a month.

If the month has 28 days, it will always have 20 working days (assuming a 5 day work week). Therefore you only need to check the if the days of the month past the 28th are work days to get the total number.
ldMonthStart = {^2002/03/01}
ldMonthEnd = {^2002/03/31}
lnDaysInMonth = ldMonthEnd - ldMonthStart + 1

lnWorkDays = 0
IF lnDaysInMonth > 28
	FOR i = 28 TO lnDaysInMonth - 1
		lnDayOfWeek = DOW(ldMonthStart + i,1) && get day of week forcing Sunday to be 1
		IF lnDayOfWeek <> 1 AND lnDayOfWeek <> 7 && not Sunday or Saturday
			lnWorkDays = lnWorkDays + 1		
		ENDIF
	ENDFOR
ENDIF
? 20 +lnWorkDays
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform