Skip to main content

I have looked on line and I am not seeing any help for calculating weekdays between 2 fields that are Date/Time - everything I find is for Date only fields.

 

I have created a formula to calculate the days but need it to be weekdays only

 

Handoff Date = Starting Date

Approval Date = ending date

 

CURRENT FORMULA

IF(ISNULL(Approved_Date__c ) , NOW() - Contract_Review__r.HandoffDate__c , Approved_Date__c - Contract_Review__r.HandoffDate__c )

 

Does anyone know how to make this work for Date/Time fields?

13 Antworten
  1. 30. Jan. 2024, 14:57

    You can't do math with a NULL, BLANK, or nothing.  So if the Approved_Date__c field is blank, then you need to supply a substitute Date or value.  For this I like to use a BLANKVALUE Function, like this

    IF(

    ISBLANK( Hand_Off_Date__c ),

    NULL ,

    (5 * ( ROUND( (( DATEVALUE( BLANKVALUE( Approved_Date__c , NOW()) - 5 )

    -

    DATE( 1900, 1, 8) ) / 7 ) , 2 ) )

    +

    MIN( 5, ROUND( MOD( DATEVALUE( BLANKVALUE( Approved_Date__c , NOW()) - 5 )

    -

    DATE( 1900, 1, 8), 7 ) , 2 )) )

    -

    (5 * ( ROUND( (( DATEVALUE( Hand_Off_Date__c - 5 )

    -

    DATE( 1900, 1, 8) ) / 7 ) , 2 ) )

    +

    MIN( 5, ROUND( MOD( DATEVALUE( Hand_Off_Date__c - 5 )

    -

    DATE( 1900, 1, 8), 7 ) , 2 )) )

    )

    PS.  Remember to select "Treat blank fields as BLANKS" (not zeroes) otherwise everything breaks

0/9000