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

Report Loop Question

Status
Not open for further replies.

edwindow

Programmer
Jul 13, 2001
51
US
This is the first time I have used a Loop control function so I am guessing as to how it is suppose to work. Basically, I am taking a From and To parameter and trying to find out how many work days there are between the two dates; however, I need to filter out weekends. I figured I could do this with a loop, but if there is an easier way to do this please let me know.
This is the code I came up with. I seem to be getting the error 'missing key word do'

Code:
dateVar x;
x:=({?From});

while ((dayofweek((x),crSunday)<>1) and (dayofweek((x),crSunday)<>7)=true) and (x<{?To})) do

(count(x:=x+1))

exit while;


 
Hi

See Ken Hamady's useful formulas at his website.

Geoff
 
Here is Ken's formula address.
The advantage to Ken's is that includes code for eliminating holidays from the total.


Here's a loop I created that counts weekdays from &quot;today&quot; to the end of the month. It does not take into consideration holidays.

datevar firstday;datevar lastday;numbervar loop;numbervar wds; numbervar span;
firstday:=today;
if month(firstday)=12 then lastday:=date(year(firstday)+1,1,1)-1
else lastday:=date(year(firstday),month(firstday)+1,1)-1;

span:=lastday-firstday;
For loop:= 0 to span do(
if dayofweek(firstday+loop)in [2 to 6] then wds:=wds+1 else wds:=wds);

wds




Mike
 
your specific problem is the use of &quot;Exit While&quot;

this is use to conditionally exit the while loop and the way you have it written it does not have a condition and it is outside the loop structure.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top