Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Walk through date range in a variable for an array

Status
Not open for further replies.

txgeekgirl1

Programmer
Sep 10, 2009
85
US
I am trying to walk a date range using a For variable to compare to an array. I am getting a not numeric nesting error - it seems to be in the walk between the svcdate and createdate - FOR x = Casedata_.svcdate TO Casedata_.CreateDate. Any help is much appreciated.

Code:
IF Casedata_.CreateDate - Casedata_.SvcDate > 2 THEN
			LOCAL x, y
			STORE {} TO x
			STORE 0 TO y
			
			FOR x = Casedata_.svcdate TO Casedata_.CreateDate
			messagebox(DTOC(x))                          *------------------This coming up   /  /
				IF DOW(x,2) <> 6 OR DOW(x,2) <> 7 THEN
					FOR y = 1 TO 50
						IF x = holidayarray[y] THEN
							messagebox(str(lnNewDays))
							lnNewDays = lnNewdays - 1
							messagebox(str(lnNewDays))
						ENDIF
					NEXT y
				ENDIF
			NEXT x
		ENDIF
 
The least thing you could do is name the array holidayhooray. [santa3]

53 holidays to 2023. All german states have 10 holidays per year, some states in germany have up to 4 extra holidays (catholic). Though some of these holidays are fixed on sunday, most are fixed on date and some even on a weekday. At least now I feel a little more comfortable about that slight difference of my state (Hamburg) vs the most "lazy" state (Bayern), still a good share of holidays even for all german states only having the 10 common holidays. In germany there is a "north-south business gradient" and the largest turnover copanies are in the south, where they also have the most holidays. Speaks for the necessity and usefulness of recreation. The german employee and also civil servants will have additional 30 holidays (PTO) per year.

I wouldn't bet on the software still running in 2023, not just because it's VFP, from that perspective it's surely "safe". There will be harder problems. One holiday we have introduced in 1990 nobody thought would exist just one or two years before that - alone for that reason I'd never hardcode such data.

Since your date ranges are seldom longer than 2 days it's also good enough, but you'd have a huge performace advantage with an indexed table to compute business day counts for longer date ranges, maybe even spanning multiple years. Then it wouldn't only be about the maintainability aspect. Even in your routine you could just iterate the array once and test each stored holiday being between your start and end date.

Bye, Olaf.
 
Olaf - My daughter lives in Koln and does enjoy the extra holidays along with her vacation. She most appreciates that in Germany - most companies don't scoff at a 3 week vacation, especially if traveling to the U.S. or crossing an ocean. Also that between Christmas and New Years most companies shut down as extra time off. Me - I get 3 weeks PTO a year but am lucky to get 1 full week off a year.

We are running old legacy VFP... I think version 6. I don't see us running past 2 more years.
 
>most companies shut down as extra time off

Well, I saw that at one company being a customer, but the employees have to take holidays for that week, too. So it's not an extra, you're rather forced to take part of your 30 days PTO for that week. Might be different in other companies, but it would be new to me this is usual. It is just very usual to take holidays in that season, as we also celebrate Holy Night already and of course Silvester and New Years Eve, you seldom need many PTOs to fill in the whole week between the years.

Bye, Olaf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top