GetDayOccurrence ( )

Function stats

Average user rating
74
157
9999
Support
FileMaker 7.0 +
Date posted
21 December 2008
Version
1
Recursive function
No

Author Info
 Ken Newell

3 functions

Average Rating None

author_avatar



 

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

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)