Sunday, November 11, 2018

How to get Days, Hours and Minutes in specified format when two datetime fields are subtracted in formula field in salesforce

In this post we would learn how to get Days, Hours and Minutes in specified format when two datetime fields are subtracted in formula field in salesforce ?

Solution: 

TEXT(
FLOOR((Now()- CreatedDate))
) & " Days " &
TEXT(
FLOOR(MOD(((Now()- CreatedDate))*24,24))
) &" Hours " &
TEXT(
ROUND(MOD(((Now()- CreatedDate))*24*60),0)

)

you can replace Now() and createddate according to your datetime fields which you want to get datetime from.