Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Work days between two dates - finally!
Message
De
09/06/2003 09:27:59
 
 
À
09/06/2003 09:23:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00797684
Message ID:
00797939
Vues:
22
Whoops!! Just noticed it still doesn't work for k = 0 or k = 1. Back to the drawing board.
On the other hand, If k < 5 how can one know which days are not work days in order to calculate the true number of work days between the 2 dates? At least with k = 5, we can assume Saturday and Sunday being non-work days. Even with k = 6, how can we know if Saturday is the day off or Sunday. Depending on the dates sent to the function, I don't see how you can possibly return an accurate number without it being a guess.

Alan

>>Hi Cetin,
>>
>>this program for:
>>
>>({^2003/6/10},{^2003/6/16},k) return fixed 5 for every k=0-7.
>>
>>Fabio
>
>Try couple of minor changes:
>
>LPARAMETERS td1, td2, tnWorkDaysInWeek
>* First day of workday is Monday - 2
>LOCAL lnDays
>
>IF td2 < td1
>	LOCAL ldTemp
>	ldTemp = td1
>	td1 = td2
>	td2 = ldTemp
>ENDIF
>
>tnWorkDaysInWeek = IIF(EMPTY(tnWorkDaysInWeek),5,;
>                   IIF(tnWorkDaysInWeek > 7, 7, tnWorkDaysInWeek))
>lnFullWeeks = FLOOR((td2-td1)/7)
>td1 = td1+lnFullWeeks*7
>IF DOW(td1,2) > tnWorkDaysInWeek
>  td1 = IIF(DOW(td2,2) > tnWorkDaysInWeek, ;
>  	td1 + ABS(DOW(td1,2)-DOW(td2,2)), td1 + 7-DOW(td1,2))
>ENDIF
>
>lnAdd = IIF(DOW(td1,2) > tnWorkDaysInWeek, 0, 1 )
>
>lnDays = IIF(DOW(td1,2) > DOW(td2,2), ;
>	7 - lnAdd - DOW(td1,2) + DOW(td2,2), ;
>	lnAdd + MIN(DOW(td2,2),tnWorkDaysInWeek) ;
>	- MIN(DOW(td1,2),tnWorkDaysInWeek) )
>
>RETURN lnFullWeeks * tnWorkDaysInWeek + lnDays + (tnworkdaysinweek - 5)
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform