General information
Category:
Coding, syntax & commands
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
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only