Brian Dunning's FileMaker Custom Functions

calcEndDate ( startDate ; numDays ; loopCount ; holidayList ; allowWeekends ; direction )

Calculate date by adding or subtracting days, option for skipping weekends

  Average rating: 3.8 (46 votes) Log in to vote

Shan Younker   Shan Younker
Shan Younker
-none

Share on Facebook Share on Twitter

  Sample input:
CalcEndDate (9/9/2009; 5; 0; $$holidayList; "" ; "b")
  Sample output:
9/1/2009

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Function for calculating an end date based on a start date and a number of days. Function has options to calculate forward or backwards and can allow for an end date to fall on a weekend or holiday or not. The function is a simple recursive loop that adds or subtracts one day from the start date each time through the loop, no complicated date formulas required. When the number of times through the loop equals the number of days originally passed to the function, the function returns the calculated date. If the flag is set to allow a weekend/holiday end date, the function does simply adds or subtracts the number of days from the start date.

 

Comments

Jeffrey E. Bloch   Jeffrey E. Bloch, Fairfield, CT
Feb 15, 2011
Brian,

Great work!

The only issue I have is:

REPORT
Start Date: 3-15-10
End Date: 4-15-10

If I prepare a report in any given database, based upon these dates, and want to compare the results with data from each of the past 6 months, how many days do I tell your custom function to back up since some months have more/less days than others?

Thanks!!

jeff@theccsgroup.net

I hope you don't mind me asking.
 
Jeffrey E. Bloch   Jeffrey E. Bloch, Fairfield, CT
Feb 15, 2011
Sorry Shan, I noticed this was briandunning.com and assumed these were his.

Nice work!
 
Jeff Byers   Jeff Byers, Ft. Lauderdale, FL
Mar 9, 2013
Hi,

I'm using this custom function... calcEndDate...
which is working fine at excluding weekend dates.

However, I'm having trouble incorporating my holidayList of exclusion
dates, into the function.

I currently have a separate Holiday List file of 10 holiday records/dates.

If I am understanding correctly... I need to get these 10 date records
into a single global field, for the function to exclude the holidays from.

Not sure if this is the correct approach... please advise.

I also took the approach, of setting up a separate table, with 10 individual records... but ended up with the same resulting conundrum...

I believe the calcEndDate function requires a single global field of holiday dates.

It seems I'm still not grasping the simplicity of what needs to be done.

The sample input references $$holidayList...
however I'm not well versed in the use of global variables yet.
 
Fred   Fred, CA
Oct 9, 2017
For the holidayList, just create a field and set it to Global. In the field, just list out the holidays dates, one date per line as such:

10/12/2017
10/25/2017
11/4/2017
11/15/2017
12/25/2017

No commas seem to be needed.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.