Function overview
Prototype
GetDayOccurrence (
TheDate; Weekday; Reps )
Parameters
TheDate
Weekday
Reps
Description
Tags:
Day Of The Week Day Date
By passing the parameters TheDate, Weekday, Reps to this custom function you can find a date in the future. For example: The 4th Tuesday from 12/20/2008 is 1/13/2009, the 10th Friday from 1/1/2009 is 3/6/2009.
Complete version notes can be found in the Custom Function.
Examples
Sample input
GetDateOccurrence ( GetAsDate ( "1/1/2009") ; "Fri" ; 10 )
Sample output
3/6/2009
Function code
/*
==================================================
05/30/2004 1.0 KLN Original Version
==================================================
PURPOSE: Gives the Nth Occurance from a given date. Returns
"" If Improper weekday is entered or less than 1 reptation (i.e. only calculates forward to a date in the future). Format for WeekDay is
the same as returned by FM with the DayName() function or can
be a standard three letter day format. A date is returned.
==================================================
USER INPUTS
TheDate = The Date anchor
Weekday = Name of day to find
Reps = Number of day cycles in the future to find
VAIRABLES
None
OTHER CUSTOM FUNCTIONS USED
None
==================================================
*/
Let (DayToGet =
Case(
Weekday = "Sunday" or Weekday = "Sun"; 1;
Weekday = "Monday" or Weekday = "Mon"; 2;
Weekday = "Tuesday" or Weekday = "Tue"; 3;
Weekday = "Wednesday" or Weekday = "Wed"; 4;
Weekday = "Thursday" or Weekday = "Thr"; 5;
Weekday = "Friday" or Weekday = "Fri"; 6;
Weekday = "Saturday" or Weekday = "Sat";7;0);
If ( DayToGet=0 or Reps < 1 ; "" ;
If (DayToGet = DayOfWeek ( TheDate ); TheDate + (Reps *7);
If ( DayOfWeek ( TheDate ) < DayToGet; TheDate + (DayToGet -DayOfWeek( TheDate)) + ((Reps-1) * 7) + 1;
TheDate - (DayOfWeek ( TheDate ) - DayOfWeek ( DayToGet ))+ (Reps) * 7) - 1
)))
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/157
Prototype: GetDayOccurrence( TheDate; Weekday; Reps )
Function Author: Ken Newell (http://www.fmfunctions.com/mid/74)
Last updated: 21 December 2008
Version: 1
*/
// ===================================
/*__LITBR__==================================================__LITBR__ 05/30/2004 1.0 KLN Original Version__LITBR__==================================================__LITBR__PURPOSE: Gives the Nth Occurance from a given date. Returns__LITBR__ "" If Improper weekday is entered or less than 1 reptation (i.e. only calculates forward to a date in the future). Format for WeekDay is __LITBR__the same as returned by FM with the DayName() function or can __LITBR__be a standard three letter day format. A date is returned.__LITBR__==================================================__LITBR__USER INPUTS__LITBR__ TheDate = The Date anchor__LITBR__ Weekday = Name of day to find__LITBR__ Reps = Number of day cycles in the future to find__LITBR____LITBR__VAIRABLES__LITBR__ None__LITBR____LITBR__OTHER CUSTOM FUNCTIONS USED__LITBR__ None__LITBR__==================================================__LITBR__ */__LITBR__Let (DayToGet = __LITBR__ Case(__LITBR__ Weekday = "Sunday" or Weekday = "Sun"; 1;__LITBR__ Weekday = "Monday" or Weekday = "Mon"; 2;__LITBR__ Weekday = "Tuesday" or Weekday = "Tue"; 3;__LITBR__ Weekday = "Wednesday" or Weekday = "Wed"; 4;__LITBR__ Weekday = "Thursday" or Weekday = "Thr"; 5;__LITBR__ Weekday = "Friday" or Weekday = "Fri"; 6;__LITBR__ Weekday = "Saturday" or Weekday = "Sat";7;0);__LITBR____LITBR__If ( DayToGet=0 or Reps < 1 ; "" ; __LITBR__ If (DayToGet = DayOfWeek ( TheDate ); TheDate + (Reps *7);__LITBR__ If ( DayOfWeek ( TheDate ) < DayToGet; TheDate + (DayToGet -DayOfWeek( TheDate)) + ((Reps-1) * 7) + 1;__LITBR__ TheDate - (DayOfWeek ( TheDate ) - DayOfWeek ( DayToGet ))+ (Reps) * 7) - 1__LITBR____LITBR__)))__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/157__LITBR____LITBR__ Prototype: GetDayOccurrence( TheDate; Weekday; Reps )__LITBR__ Function Author: Ken Newell (http://www.fmfunctions.com/mid/74)__LITBR__ Last updated: 21 December 2008__LITBR__ Version: 1__LITBR____LITBR__*/__LITBR__// ===================================