I did some searching before I decided to ask this question, as most of calculating business dates refer to a date/time field, and I only need it for just regular date fields. The business case is that I track internal SF and general Tech requests and I have a Start Date and an End Date. I don' go by the created date, as often I have to open up tickets and back date what the start date should have been, or adjust the actual start date from the created date.
I have a field called # of Days Open and at this time, this is the formula.
IF( ISBLANK( Close_Date__c ) , TODAY() - Start_Date__c , Close_Date__c - Start_Date__c )
I want to modify it, to account for business days (ie, not counting Sat and Sun, in the calculation). At this time I don't care about Holidays, as I am not sure how to even do that, as we don't get all of the Standard Holidays off.
I was able to create this formula (based off a blog post) but it doesn't take into account if the request is still open like my IF statement.
ABS(
CASE(MOD (Start_Date__c- DATE(1985,6,24),7),
0 , CASE( MOD(Close_Date__c - Start_Date__c
,7),1,2,2,3,3,4,4,5,5,5,6,5,1)
,
1 , CASE( MOD(Close_Date__c - Start_Date__c
,7),1,2,2,3,3,4,4,4,5,4,6,5,1),
2 , CASE( MOD(Close_Date__c - Start_Date__c
,7),1,2,2,3,3,3,4,3,5,4,6,5,1),
3 , CASE( MOD( Close_Date__c - Start_Date__c
,7),1,2,2,2,3,2,4,3,5,4,6,5,1),
4 , CASE( MOD( Close_Date__c - Start_Date__c
,7),1,1,2,1,3,2,4,3,5,4,6,5,1),
5 , CASE( MOD( Close_Date__c - Start_Date__c
,7),1,0,2,1,3,2,4,3,5,4,6,5,0),
6 , CASE( MOD( Close_Date__c - Start_Date__c
,7),1,1,2,2,3,3,4,4,5,5,6,5,0),
999)
+
(FLOOR((( Close_Date__c ) - ( Start_Date__c) )/7)*5)-1 +
( Close_Date__c - Start_Date__c) - (Close_Date__c -
Start_Date__c))
I also don't pretend to completely understand how this formula is working (just a plain ole Admin here) but I am thinking there has to be a way to do it without basically repeating this(?)
Thoughts?
Eric Burté (DEVOTEAM) Forum Ambassador
Hello @Heath Parks please have a look at this online help article on the same subject :
https://help.salesforce.com/s/articleView?id=sf.formula_examples_dates.htm&type=5
Find the Number of Weekdays Between Two Dates
Calculating how many weekdays passed between two dates is slightly more complex than calculating total elapsed days. In this example, weekdays are Monday through Friday. The basic strategy is to choose a reference Monday from the past and find out how many full weeks and any additional portion of a week have passed between the reference date and your date. These values are multiplied by five for a five-day work week, and then the difference between them is taken to calculate weekdays.
(5 * ( FLOOR( ( date_1 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_1 - DATE( 1900, 1, 8), 7 ) ) )
-
(5 * ( FLOOR( ( date_2 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_2 - DATE( 1900, 1, 8), 7 ) ) )
PS : it will not handle if the case is in stand by within the overall period. It will just consider the difference between both dates
PPS : Could you please explain the IF rule you have mentioned on your post. How do you expect the calculation to be impacted ?
Eric