Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Work days between two dates - finally!
Message
De
09/06/2003 07:52:46
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/06/2003 07:42:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00797684
Message ID:
00797907
Vues:
19
>Hi Cetin,
>
>What was the error in Message #791711 ?
>for {^2003/6/15},{^2003/6/15} return -1, correct is 0.
>
>Last program:
>for {^2003/6/14},{^2003/6/16} return 2, correct is 1.
>
>Fabio

Good catch :)
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,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 
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform