Domino Code Fragment

Code Name*
Calendar Set-Up
Date*
01/15/2001
Source (or email address if you prefer)*
<Wellford Dowdy> FourDowdys@cs.com
IP address:.12.26.69.6
Description*
The code determines the date of the first Monday in any given calendar year. @Adjust can be used to determine the dates on which subsequent weeks begin and end. Use it to create a form that serves as a schedule or scheduler. (FIELD FR_2 := @Adjust(FR_1;0;0;7;0;0;0);
FR_2)
Type*
Formula
Categories*
Date/Time Handling
Implementation:
None (plug and play)
Required Client:
(none)
Server:
(none)
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
REM "Create working varibles for: year (received as a parameter)," ;
FIELD Year := @TextToNumber(Year);

REM " date to evaluate (01/01/Year)";
FIELD EvalDt:= @Date(Year;1;1);

REM " weekday of 01/01/Year";
FIELD WkDy := @Weekday(EvalDt);

REM "if day is Mon, adjust 0 days!";
REM "if day is Sun, adjust 1 days to next Mon";
REM "if day is Tue, adjust 6 days to next Mon";
REM "if day is Wed, adjust 5 days to next Mon";
REM "if day is Thu, adjust 4 days to next Mon";
REM "if day is Fri, adjust 3 days to next Mon";
REM "if day is Sat, adjust 2 days to next Mon";

FIELD FR_1:= @Adjust(EvalDt;0;0;@If(WkDy=2;0;
@If(WkDy=1;1;
@If(WkDy=3;6;
@If(WkDy=4;5;
@If(WkDy=5;4;
@If(WkDy=6;3;
@If(WkDy=7;2; @Failure("Error in date math. Please contact the database support person under Help | About This Database"))))))));0;0;0);

REM "Return the first Mon of the given year";
FR_1