Skip to main content
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.
1 个回答
  1. 2019年2月9日 20:29
    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

     
0/9000