Manage Learn to apply best practices and optimize your operations.

Adjust A Date Forward Any Number Of Business Days

This formula should adjust any given date forward (or backwards) by any given
number of business days. This formula skips weekends (accounting for them in
the adjustment). If you are adjusting a date forward and the date falls on the
weekend, it will be moved back to friday and then adjusted. Likewise, if you
are adjusting a date backwards and the date falls on the weekend, it will be
moved forward to monday and then adjusted.

The variable 'tmpAdjBy' must be an integer value.
The variable 'adjDate' must be a valid date.
tmpAdjBy := +/-??;
adjDate := ??/??/??;

adjUp := tmpAdjBy > 0;
adjBy := @Abs(tmpAdjBy);
preDay := @Weekday(adjDate);
preAdj := @If(preDay = 7; @If(adjUp; -1; 2); preDay = 1; @If(adjUp; -2; 1); 0);
startDate := @Adjust(adjDate; 0; 0; preAdj; 0; 0; 0);
startDay := @Weekday(startDate)-1;
firstAdj := ((((startDay + adjBy) > 5) * adjUp) + (((adjBy - (startDay - 1)) >
0) * !adjUp)) * 2;
adjCnt := ((adjBy - (5 - startDay)) * adjUp) + ((adjBy - (startDay - 1)) *
!adjUp);
secondAdj := @Integer((((adjCnt > 5) * 1) * adjCnt) / 5) * 2;
totalAdj := adjBy + (@If(startDay = @If(adjUp; 5; 1) & adjBy > 5;
([email protected](adjBy; 5)); 1) * firstAdj) + secondAdj;
ANSWER := @Adjust(startDate; 0; 0; totalAdj * @If(adjUp; 1; -1); 0; 0; 0);

Dig Deeper on Lotus Notes Domino Calendar and Contact Management

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close