function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kimberly Garcia 5Kimberly Garcia 5 

Flow: Input Validation Formula- Is date less than 5 business day

Within one of our flows we have a screen that asks for a requested send date, this date should never be less than 5 business days and I'd like to make an input validation that gives an error if it is less than 5 business days. I've been trying to play with the weekday function and incorporate the greater than or equal to since my formula expression has to be true in order for the error to appear and I'm having no luck getting it to work.
Alain CabonAlain Cabon
Hi,

Formula to calculate number of days or Business Days between dates
  • 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
https://help.salesforce.com/articleView?id=000004526&type=1
CASE(MOD( StartDate__c - DATE(1985,6,24),7), 

  0 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 
  1 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 
  2 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 
  3 , CASE( MOD( EndDate__c - StartDate__c ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 
  4 , CASE( MOD( EndDate__c - StartDate__c ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 
  5 , CASE( MOD( EndDate__c - StartDate__c ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 
  6 , CASE( MOD( EndDate__c - StartDate__c ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 
  999) 
  + 
  (FLOOR(( EndDate__c - StartDate__c )/7)*5)

1. Create a formula field that returns a number ( Weekdays__c )
2. Paste the formula.
3. Replace StartDate__c and EndDate__c with your custom field values.
4. If using Date/Time fields: Replace with DATEVALUE(YourCustomDateTime__c) instead.
5. Make an input validation that gives an error if it is less than 5 business days:  Weekdays__c < 5