1

In my record I have to datetime fields, now() and Create date. I want to do the difference between them and put this difference in the form: example: TOT days TOT hours TOT minutes TOT seconds. Is it possible in Salesforce? Thanks for your help

  • Have you done any research? What have you tried so far? Where are you stuck? – Adrian Larson Jan 22 '17 at 20:53
2

You can use this code in formula field:

IF(FLOOR( (NOW()- CreatedDate)) > 0,TEXT( FLOOR( (NOW()- CreatedDate)) ) & " days ", "") 
& IF(FLOOR( MOD( (NOW()- CreatedDate)* 24, 24 ) )>0,TEXT( FLOOR( MOD( (NOW()- CreatedDate)* 24, 24 ) ) ) & " hours ","") 
& TEXT( ROUND( MOD( (NOW()- CreatedDate)* 24 * 60, 60 ), 0 ) ) & " minutes "
& TEXT( ROUND( MOD( (NOW()- CreatedDate)* 24 * 60*60, 60 ), 0 ) ) & " seconds" 

It will display the value like this:

19 days 13 hours 7 minutes 53 seconds

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.