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

Business Days formula 1

Status
Not open for further replies.

kskid

Technical User
Mar 21, 2003
1,767
US
CR 8.5, Oracle with ODBC connection

Using the following formula from Ken Hamady's site to calculate 15 business days from the first of the month but am getting an error

Code:
Shared datevar SendDt;
shared datevar ReturnDt;
NumberVar Add:= 15; // put the number of days here to add (a positive number)
NumberVar Added := 0;
datevar target := dateserial(year(currentdate),month(currentdate)+1,1);

while dayofweek(target) in [1,7] or target = {CALENDAR_EXCEPTIONS.EXCEPTION_DATE}
do target = target + 1;
SendDt := target;


WHILE Added < Add 
Do (target := target +1;
    if dayofweek (target) in [2 to 6] and not (target = {CALENDAR_EXCEPTIONS.EXCEPTION_DATE}) 
        then Added:=Added+1
        else Added:=Added);
ReturnDt := Target;

The only {CALENDAR_EXCEPTIONS.EXCEPTION_DATE} I have for may is 5/30/2005, which is memorial day.

A loop was evaluated more than the maximum number of allowable times.

It worked for the month of April when I ran the report in March but cannot get May's, which should be

SendDt: 5/2/2005
ReturnDt: 5/20/2005

Any ideas?

Thanks,
-LW

 
You are missing a colon in your first "do." Try:

while dayofweek(target) in [1,7] or target = {CALENDAR_EXCEPTIONS.EXCEPTION_DATE}
do target := target + 1; //missing colon was in this line
SendDt := target;

-LB
 
Thank LB,

I looked at that for 1/2 hour and kept missing it. I should have known. I installed the formula in February and it worked for 3/1/2005 and 4/1/2005 because both days were business days. However, 5/1/2005 is a weekend date so this is the frst time the loop is used.


Thanks again.

-LW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top