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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stuck in a loop, how to counteract it?

Status
Not open for further replies.

Digitalcandy

IS-IT--Management
May 15, 2003
230
0
0
US
I am calculating business days using Ken Hamaday's code below, but I get an error stating that I've exceeded the maximum number of loops. How do I fix it?



//Subtracting Business Days:
WhileReadingRecords;
DateVar Target := Date({Table.DateTime});
NumberVar Add := -20;
NumberVar Added := 0;
WHILE Added > Add
DO (target := target -1;
if dayofweek (target) in 2 to 6
then Added:=Added-1
else Added:=Added);
Target



 
I didn't receive a loop error, but couldn't fix your formula. I did however create a formula that should work for you.


numbervar daysback:=20;//number of days back
datevar dat:= ({table.date}); start date
numbervar looper;


for looper:= 0 to daysback do(
if dayofweek(dat) in 2 to 6 then
dat:=dat-1 else

dat:=dat-3);
dat +1




Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top