Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I have been trying this piece o

Status
Not open for further replies.

sohrab

Technical User
Nov 21, 2000
18
CA
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
 
Soharb,

There is a tested formula in the FAQ that does exactly what you need. See my FAQ on common formulas. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Hi Ken,

Thanks for your help. It works Fine. Greatly Appreciated

Regards;
Sohrab
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top