Post Reply 
Casio FC-200 Financial Consultant
12-27-2020, 05:49 AM
Post: #13
RE: Casio FC-200 Financial Consultant
(12-26-2020 11:31 PM)Albert Chan Wrote:  return D-E-E - sign(D-7*E + W - 6)

If end date falls on Saturday, and start date not on Sunday, sign correction mess goes away.

Example, networkdays between 1/1/2021 (Friday) to 4/1/2021 (Thursday)

Remove the correction term by adjusting end-date to Saturday, 4/3/2022 Sat

D = 31 + 28 + 31 + 2 = 92 days
E = floor(D/7) = 13 weeks

networkdays (1/1/2020 to 4/3/2020) = D-E-E = 66
networkdays (1/1/2020 to 4/1/2020) = 66 - 1 = 65

PHP Code:
function networkdays(AB)      -- assumed date A <= B
    local M 
- (B-1)%7       -- days to Saturday
    local D 
B+A           -- -> Sat
    local E 
floor(D/7)
    if 
D-7*E==6 then D=D-1 end  -- A Sun -> Mon
    
if 1 then D=D-M+1 end
    
return D-E-E
end 
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Casio FC-200 Financial Consultant - Gamo - 12-15-2020, 12:07 PM
RE: Casio FC-200 Financial Consultant - Albert Chan - 12-27-2020 05:49 AM



User(s) browsing this thread: 1 Guest(s)