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 https://github.com/jbante/ |
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, 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, 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, india Nov 29, 2013 |
||
can i have coding for buisness days function? | ||
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. | ||
Michael Ghesquiere Feb 24, 2022 |
||
Inconsistent results? This is what I pass to the function: Set Variable [ $BeginningTS; Value:GetAsTimestamp ( "02/21/2022 08:25 AM" ) ] Set Variable [ $EndingTS; Value:GetAsTimestamp ( "02/22/2022 10:47 AM" ) ] // Set Variable [ $BeginningTS; Value:GetAsTimestamp ( "02/23/2022 9:28 AM" ) ] // Set Variable [ $EndingTS; Value:GetAsTimestamp ( "02/24/2022 11:33 AM" ) ] #Calculate number of business hours between two timestamps Set Variable [ $Beg_Date; Value:GetAsDate ( $BeginningTS ) ] Set Variable [ $End_Date; Value:GetAsDate ( $EndingTS ) ] Set Variable [ $BusinessDaysLapse; Value:BusinessDays ( GetAsDate ( $Beg_Date ) ; GetAsDate ( $End_Date ) ) ] Passing the two sets of variables results in two different results. The Feb 21, 22 returns 1, and the Feb 23, 24 returns 2. Can anyone explain the difference between the two executions? Thanks... Michael |
||
Michael Ghesquiere Feb 24, 2022 |
||
ROFL, 5 min after posting.... Feb 21 is a holiday! 2 hours wasted. Please disregard. | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.