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

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

 Shan Younker Shan Younker -none

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.

 Jeffrey E. Bloch, Fairfield, CTFeb 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, Fairfield, CTFeb 15, 2011 Sorry Shan, I noticed this was briandunning.com and assumed these were his. Nice work!
 Jeff Byers, Ft. Lauderdale, FLMar 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, CAOct 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.
 Steve KempAug 28, 2019 I've noticed an issue when using the holidayList parameter. If my dates (I'm using DD/MM/YYYY format here) doesn't have a leading zero for the day and month value the holidayList parameter doesn't work correctly. Any way to get around this?

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

# Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 16 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: