startDate; days; wkEnds )
Weekends Weekend Range Date Business Days
Calculates the end of a date range, given the start date and the number of days in the range.
Allows to specify only whether weekends are included in the day count. In other words, if wkEnds = FALSE, then it will assume that the day count is "business days," and not "calendar days". It will then add the correct number of days to account for the weekends.
There are several custom functions "out there" that do this same thing, and some even exclude holidays also. However, all the ones I could find use recursion and are significantly slower than this one, because: This just uses Math, not recursion, and is therefore much faster, especially for larger day ranges.
CalculateEndDate ( '6/4/2010' ; 8 ; 0 )
/* These first three are for testing.
* To use them, copy this function body into the Data Viewer,
* uncomment these, and then fiddle with their values as the inputs.
wkEnds = 0
; days = 7
; startDate = date ( 6; 9 ; 2010 )
;*/ gridDays = days - ( 7 - DayOfWeek ( startDate ) + 1 ) + 1
; extras = days - gridDays
; padGrid = ( Div ( gridDays ; 5 ) + ( extras < 5 ) ) * 2
; calDays = startDate + days - 1
; output = calDays + (not wkEnds) * padGrid * (extras < days)
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/258
Prototype: CalculateEndDate( startDate; days; wkEnds )
Function Author: Steve Allen (http://www.fmfunctions.com/mid/148)
Last updated: 10 June 2010