Hi, I have been trying this piece of code, in order to get number of days between 2 Dates, It seems to me this formula is not working for more than a week, meaning no matter how big your dateSpan is, the most you get is 5 days, which is the number of working days for one week. is there any way that some one please help me. Thank you in advance;
Here is the code;
dateVar array holidays := [Date(2001,1,1),Date(2001,2,19),Date(2001,5,28),Date(2001,7,4),
Date(2001,9,3),Date(2001,11,22),Date(2001,12,25)];
dateVar range drange := {@low date} to {@high date};
dateVar datecheck := {@low date};
numberVar wkday := Day (datecheck) ;
numberVar WrkCount := 0;
while (datecheck in drange) do
(
Wkday := Day (datecheck);
if Wkday in [2 to 6] then WrkCount := WrkCount + 1;
if datecheck in holidays then WrkCount := WrkCount -1;
datecheck := datecheck + 1;
);
if wrkcount < 0 then wrkcount := 0;
wrkcount
Regards;
Sohrab
Here is the code;
dateVar array holidays := [Date(2001,1,1),Date(2001,2,19),Date(2001,5,28),Date(2001,7,4),
Date(2001,9,3),Date(2001,11,22),Date(2001,12,25)];
dateVar range drange := {@low date} to {@high date};
dateVar datecheck := {@low date};
numberVar wkday := Day (datecheck) ;
numberVar WrkCount := 0;
while (datecheck in drange) do
(
Wkday := Day (datecheck);
if Wkday in [2 to 6] then WrkCount := WrkCount + 1;
if datecheck in holidays then WrkCount := WrkCount -1;
datecheck := datecheck + 1;
);
if wrkcount < 0 then wrkcount := 0;
wrkcount
Regards;
Sohrab