0

How can I show the difference of two date time fields in days and hours. I am trying to do this in a formula field or process builder.

Example: 16/10/2021 11:00am - 15/10/2021 10:00am = 1 day 1 hour

1
0

Akash,

Can you try the below?

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'
)

Let me know if you have any additional questions.

2
  • thanks it works. but now I am struggling to make it incremental like already present 1 day 1hrs + 1 day 2 hrs (like first_date_time_diff + above calculation). is it possible to do it in same formula field?
    – Akash
    Jan 8 at 9:50
  • Akash, you can adjust the formula as you need. But, it is better to avoid adding additional logic to the formula. Else, the run time will increase a lot. Jan 8 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.