Brian Dunning's FileMaker Custom Functions

BusinessDays ( startDate ; endDate )

Returns the number of business days between two dates (inclusive)

  Average rating: 4.1 (38 votes) Log in to vote

Jeremy Bante   Jeremy Bante

https://github.com/jbante/

Share on Facebook Share on Twitter

  Sample input:
BusinessDays ( Date ( 11 ; 10 ; 2011 ) ; Date ( 11 ; 30 ; 2012 ) )
  Sample output:
265

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

This function returns the number of business days (non-holiday weekdays) between startDate and endDate (including both startDate and endDate).

This function is dependent on the BusinessHolidays ( calendarYear ) function to produce a list of observed holidays in a given year.

 

Comments

Brian Rich   Brian Rich, Hampshire UK
Feb 22, 2012
Business Days() imposes a severe performance hit of several seconds if the startDate parameter is empty, and returns a ? as the result.

I added a case statement to a modified version of the function so that if the startDate or endDate are empty, or the endDate<startDate, the function returns a null value and doesn't try to evaluate - viz:

Case(
IsEmpty(startDate);"";
IsEmpty(endDate);"";
endDate<startDate;"";

Let ...
)

HTH

Brian
 
Jeremy Bante   Jeremy Bante, USA
Feb 22, 2012
Thank you for letting me know. Normally I prefer to let the consequences of bad input filter through, but performance is different. I opted to return "?" rather than null to be consistent with error behavior for FileMaker-native functions.
 
aruna   aruna, india
Nov 29, 2013
can i have coding for buisness days function?
 
Thiyagarajan   Thiyagarajan, Test
Nov 12, 2018
We have weekly holidays Friday and Saturday. Where I need to change the condition in this custom function ?. Please advise.
 

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.

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: