Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Counting Days
Message
 
À
16/10/2000 14:53:20
Erin Eby
Mission Critical Software
Gainesville, Floride, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00429936
Message ID:
00429987
Vues:
20
Here is an old FP2x function dusted off. (Apologize in advance for old variable naming conventions)


function CALCDAYS
parameters startdate, stopdate
local start_pad, stop_pad, prior_mon, next_fri, week_ends
* prior_mon - Date of Monday _prior_ to StartDate.
* start_pad - Number of days between prior Monday and StartDate.
* next_fri - Date of Friday _after_ StopDate.
* stop_pad - Number of days between StopDate and next Friday.
*** ---------- Guarantees that formula will calculate without rounding errors.
* next_fri - prior_mon will always be 4,11,18,25...n

start_pad = dow(startdate) - 2
prior_mon = startdate - start_pad

stop_pad = 6 - dow(stopdate)
next_fri = stopdate + stop_pad

week_ends = int((next_fri - prior_mon) / 7) * 2
return ((next_fri - prior_mon) - week_ends - start_pad - stop_pad)

Assumptions:
1. Doesn't exclude holidays
2. Doesn't test for StartDate coming _after_ StopDate
3. I never tested for split years.

HTH

Andrew
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform