Brian Dunning's FileMaker Custom Functions

CalculateEndDate ( startDate ; days ; wkEnds )

Calculate End Date given Start Date and number of days, inclusive; handles weekends. NOT Recursive.

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

Steve Allen   Steve Allen
Richard Carlton Consulting, Inc.

Share on Facebook Share on Twitter

  Sample input:
CalculateEndDate ( '6/4/2010' ; 8 ; 0 )
  Sample output:

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

Allows to calculate the end of a date range, given the start of the range, and the number of days in the range.

Has a parameter for weekends. Specifying TRUE is saying "the number of days specified includes weekends", and therefore returns the calendar day range (equivalent to Start + Days - 1).

Specifying FALSE for the weekends parameter is saying "the number of days specified does NOT include weekends -- it's only business days," and so to get the correct end date, it adds the weekends in.

There are several function "out there" that do this, but this is the only one I know of that does it using Math, not recursion. In my experience with the others, this one is much faster, especially on long ranges.



Jun 10, 2010
wkEnds fields, what type must to be?
and what includes?
When i put (0) zero then functions count correctly, but when put 1 for a holidays day, then does not work
Jeffrey E. Bloch   Jeffrey E. Bloch, Fairfield, CT
Feb 15, 2011

What if you need to subtract multiple months from a date, maintaining the same "day" (ie. 15th of the month)? This seems complex since some months have more days than others.

Steve   Steve, Fairfield, CA
Feb 15, 2011

The built-in Date function will allow you to do that.

Just use:

Date (
Month ( mydate ) - number_of_months_to_subtract
; Day ( mydate )
; Year ( mydate )

FileMaker will take care of the rest.


Steve Allen
Daniel Wood   Daniel Wood, Digital Fusion Ltd
Apr 21, 2011
Hi Steven, I've found an issue with this function but not sure how to resolve it. I was trying to use it to calculate the end date after X working days excluding weekends:

Start Date = 25/7/2011 (25 July)
Days: 26
Exclude weekends

The function gives me an end date of 27/8/2011 , which is actually a saturday. The result I would expect is 29th of August which is the monday.

I have checked this manually and the final day after 26 is definitely the 29th. The function is beyond me in terms of figuring out how to fix it sorry.
Chris Wessels   Chris Wessels, Sydney, Australia
Jan 25, 2012
I, like Daniel found a problem with this. I came up with the following, which seems to be working nicely:

Note: Unlike Steven's original function, this one always excludes week ends....

Let ([
/* Calculates startDate + days excluding week ends */
day = If(DayOfWeek(startDate)=1;7;DayOfWeek(startDate)-1)
; output = startDate + days + If(day = 6; 2 ; 0) +
(Floor ( ( days -1 + ( If(day=6;1; Mod ( day ; 6 )^1 ) ) ) /5 ) *2 )

dansmith65   dansmith65, BC, Canada
Jun 2, 2016
With Chris's version, an input date of date ( 5 ; 28 ; 2016 ), I expected Date ( 6 ; 10 ; 2016 ), but got Date ( 6 ; 13 ; 2016 ).

It may be an edge case, but it seems like a date starting on the weekend produces unexpected results. I ended up using CompletionDate by Daniele Raybaudi:
Joshua Paul   Joshua Paul, Neo Code
May 7, 2018
The original function is not useful.

But Chris Wessels function is good.


Let ([
/* Calculates startDate + days excluding week ends */
day = If(DayOfWeek(startDate)=1;7;DayOfWeek(startDate)-1)
; output = startDate + days + If(day = 6; 2 ; 0) +
(Floor ( ( days -1 + ( If(day=6;1; Mod ( day ; 6 )^1 ) ) ) /5 ) *2 )


Log in to post comments.


Note: these functions are not guaranteed or supported by 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 15 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:

Under construction. Email me your wish list for improvements.