I apologize if this has already been answered, but I didn't find the thread. I'm looking for a way to find the business day 30 days from a start date. In my example I'm using the current date. The formula just counts 30 days and ignores the If/then conditions. Any help would be greatly appreciated.
-------------------------------
beforereadingrecords;
local numbervar counter := 0; //counter for the loop in the formula
datevar BusinessDate := CURRENTDATE; //Initialize display date to current date
datevar startdate := CURRENTDATE; //Initialize start/loop date to current date
//Initialize holiday array
datevar array holidays := [Date(2004,01,01), Date(2004,01,19), Date(2004,02,16), Date(2004,05,31), Date(2004,07,05), Date(2004,09,06), Date(2004,10,11), Date(2004,11,11), Date(2004,11,24), Date(2004,12,25)];
while counter < 30 do // Count 30 days
(
if dayofweek(startdate + counter) in [7, 1] // weekends
or startdate + counter in holidays
then
BusinessDate := startdate // Basically, do nothing
else
BusinessDate := startdate + counter; //Assign the current value of the start date to the business date
counter := counter + 1; // increment counter
);
BusinessDate // return business date
-------------------------------
beforereadingrecords;
local numbervar counter := 0; //counter for the loop in the formula
datevar BusinessDate := CURRENTDATE; //Initialize display date to current date
datevar startdate := CURRENTDATE; //Initialize start/loop date to current date
//Initialize holiday array
datevar array holidays := [Date(2004,01,01), Date(2004,01,19), Date(2004,02,16), Date(2004,05,31), Date(2004,07,05), Date(2004,09,06), Date(2004,10,11), Date(2004,11,11), Date(2004,11,24), Date(2004,12,25)];
while counter < 30 do // Count 30 days
(
if dayofweek(startdate + counter) in [7, 1] // weekends
or startdate + counter in holidays
then
BusinessDate := startdate // Basically, do nothing
else
BusinessDate := startdate + counter; //Assign the current value of the start date to the business date
counter := counter + 1; // increment counter
);
BusinessDate // return business date