February 9, 2021

Salesforce Formula Field for Date time difference

Sample Formula:

IF(
CONTAINS( TEXT( End_Date_Time__c - Start_Date_Time__c ), '.' ),
IF(
DATEVALUE( End_Date_Time__c ) = DATEVALUE( Start_Date_Time__c ),
'0',
MID( TEXT( End_Date_Time__c - Start_Date_Time__c ), 0, FIND( '.', TEXT( End_Date_Time__c - Start_Date_Time__c ) ) - 1 )
)
& ' Day(s) ' &
TEXT( ROUND( VALUE( MID( TEXT( End_Date_Time__c - Start_Date_Time__c ), FIND( '.', TEXT( End_Date_Time__c - Start_Date_Time__c ) ), 18 ) ) * 24, 2 ) )
& ' Hour(s)',
TEXT( End_Date_Time__c - Start_Date_Time__c ) & ' Day(s) 0 Hours'
)
 
Output:
 



 

No comments:

Post a Comment