Difference Between Two Datetime Fields in Salesforce Formula Field
Sample Code:
IF (FLOOR((EndDateTime__c - StartDateTime__c)) > 0, TEXT(FLOOR((EndDateTime__c - StartDateTime__c)) ) & " Days ", "") & IF(FLOOR(MOD((EndDateTime__c - StartDateTime__c)* 24, 24 )) > 0, TEXT(FLOOR(MOD((EndDateTime__c - StartDateTime__c)* 24, 24 ))) & " Hours ","") & TEXT(ROUND(MOD((EndDateTime__c - StartDateTime__c)* 24 * 60, 60 ), 0)) & " Minutes " & TEXT(ROUND(MOD((EndDateTime__c - StartDateTime__c)* 24 * 60*60, 60 ), 0)) & " Seconds"