I want to calculate days between two dates excluding weekends and Holidays which i added in salesforce. So how can i do it ? If any one have any formula for this one,Please Send me the solution...Thanks.
Calculate the number of days between two dates while excluding weekends or weekdays. Formulas provided:
1. Weekday Count Formula 2. Weekend Days Count Formula Steps to create: 1. Create a formula field that returns a number. 2. Paste in one of the two formulas. 3. Replace StartDate__c and EndDate__c with your custom field values. 4. If using Date/Time fields: Replace with DATEVALUE(YourCustomDateTime__c) instead.
Notes: Weekdays are defined as Mon-Fri and weekends as Sat & Sun Holidays are not addressed
June 24, 1985 is a long distant Monday used as a reference point The result will include BOTH the START and END dates. Mon-Sun is counted as 5 Weekdays and 2 Weekend Days.
Mon-Fri is NOT (Fri subtract Mon) = 4 Elapsed Days. Sat-Sun is NOT (Sun subtract Sat) = 1 Elapsed Day. If you use another Formula field as the start or end dates you MAY hit a compilation limit.
Workaround - Use workflow rules to save the output of the formula fields into a regular date field.
REMINDER: Be sure to TEST the formulas FIRST. Weekday Count Formula:
I found this blog which solved the problem of excluding holidays from the formula via the creation of a flow+process builder combo - it worked great for me :)
Please refer to below.
Calculate the number of days between two dates while excluding weekends or weekdays.
Formulas provided:
1. Weekday Count Formula
2. Weekend Days Count Formula
Steps to create:
1. Create a formula field that returns a number.
2. Paste in one of the two formulas.
3. Replace StartDate__c and EndDate__c with your custom field values.
4. If using Date/Time fields:
Replace with DATEVALUE(YourCustomDateTime__c) instead.
Notes:
Weekdays are defined as Mon-Fri and weekends as Sat & Sun
Holidays are not addressed
June 24, 1985 is a long distant Monday used as a reference point
The result will include BOTH the START and END dates.
Mon-Sun is counted as 5 Weekdays and 2 Weekend Days.
Mon-Fri is NOT (Fri subtract Mon) = 4 Elapsed Days.
Sat-Sun is NOT (Sun subtract Sat) = 1 Elapsed Day.
If you use another Formula field as the start or end dates you MAY hit a compilation limit.
Workaround - Use workflow rules to save the output of the formula fields into a regular date field.
REMINDER: Be sure to TEST the formulas FIRST.
Weekday Count Formula: Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
https://munawirrahman.medium.com/count-duration-exclude-weekends-and-public-holidays-in-salesforce-without-any-codes-285277df35d