Information générale
Catégorie:
Codage, syntaxe et commandes
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement