The formula code below calculates the third thursday of the month. You can get the first, second, third or fourth whatever day just by editing the DaysTemp line. Basically, the 5 in the example is the day of the week - Thursday. The 21 & 14 calculate which week. Second week would be the 14 and 7 respectively instead of 21 & 14...
TempPlusDate:= @Adjust(@Today;0;1;0;0;0;0);
TempMonthPlus:= @Month(TempPlusDate);
TempYearPlus:= @Year(TempPlusDate);
TempDate:= @Date(@TextToTime(@Text(TempMonthPlus) + "/1/" + @Text(TempYearPlus)));
WeekDayTemp:=@Weekday(TempDate);
DaysTemp:= @If(WeekDayTemp>5; (5 - WeekDayTemp) + 21; (5 - WeekDayTemp) + 14);
Temp:= @Adjust(TempDate; 0; 0; DaysTemp; 0; 0; 0);
@If(EventDate=""; Temp; EventDate)
Variation:
The code below looks up the last date in a calendar view and then does the third week of the following month.
server := @Name([CN]; @Subset(@DbName; 1));
db := @Subset(@DbName; -1);
view:= "CalendarNextMeetingLookup";
LastMeetingDate := @Subset(@DbColumn( "" : "NoCache" ; server : db ; view ; 1 ); -1);
TempPlusDate:= @Adjust(@TextToTime(LastMeetingDate);0;1;0;0;0;0);
TempMonthPlus:= @Month(TempPlusDate);
TempYearPlus:= @Year(TempPlusDate);
TempDate:= @Date(@TextToTime(@Text(TempMonthPlus) + "/1/" + @Text(TempYearPlus)));
WeekDayTemp:=@Weekday(TempDate);
DaysTemp:= @If(WeekDayTemp>5; (5 - WeekDayTemp) + 21; (5 - WeekDayTemp) + 14);
Temp:= @Adjust(TempDate; 0; 0; DaysTemp; 0; 0; 0);
@If(EventDate=""; Temp; EventDate)
Author: Tripp Black
previous page
|