By
Published: 08 Jul 2003
If you've ever had to determine a specific day of the month, for example the third Tuesday or the first Thursday, then this formula can help you out. It was designed to determine an upcoming specified day of the month, but can be easily altered to determine the specified day for any date input by replacing the @Now with your date.
REM "Enter cardinal number of the
ordinal you want. (eg. "first" = 1, "third" = 3)";
ordinal := 3;
REM "Enter the numeric day of the week
(dow). ("Sunday" = 1 to "Saturday" = 7)";
reqdow := 3;
REM "========== End Developer Changes
==================";
minday := ((ordinal -1) * 7) + 1;
curyear := @Year(@Now);
curmonth := @Month(@Now);
curday := @Day(@Now);
curdow := @Weekday(@Date( curyear ;
curmonth ; minday));
curreqday := @If(curdow > reqdow; 8 -
curdow + minday; reqdow - curdow + minday);
REM "If the date has already passed for
this month, repeat with the next month";
@If(curday > curreqday;
@Do(
@If(curmonth = 12;
@Set("curyear"; curyear + 1);
"");
@Set("curmonth"; @If(curmonth =12; 1;
curmonth + 1));
@Set("curdow"; @Weekday(@Date(
curyear ; curmonth ; minday)));
@Set("curreqday"; @If(curdow > reqdow;
(reqdow + 7) - curdow + minday; reqdow -
curdow + minday))
);
"");
REM "End getting next month's date";
specday := @Date(curyear; curmonth; curreqday);
@If(@Text(specday) = ""; @Error; specday)
Dig Deeper on Lotus Notes Domino Formula Language