function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TiratTirat 

Formula to calculate elapsed seconds between events

Hello,

 

I need to create a formula field to calculate the elapsed number of seconds between 2 Date/Time fields. The formula below:

 

EndDateTime - StartDateTime

 

Only returns the number of elapsed days. What is the formula that would return the number of elapsed seconds?

 

Thanks you.

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Multiply the differences of your two date/time fields by 84600. The calculation is a fractional number, if memory serves me correctly, so multiplying by the number of seconds in a day will yield the total number of seconds between events.

All Answers

sfdcfoxsfdcfox

Multiply the differences of your two date/time fields by 84600. The calculation is a fractional number, if memory serves me correctly, so multiplying by the number of seconds in a day will yield the total number of seconds between events.

This was selected as the best answer
TiratTirat

Thank you very much!

Worked perfectly.

Søren LandschultzSøren Landschultz
Thanks!
I got this to work but should correct the formula to: (DateTime2 - DateTime1) * 86400
...not 84600 as stated in the Best Answer.
Mohan Raj 33Mohan Raj 33
@sfdcfox Hi, If I want to provide the time differecne in the two date/time fields in hours what chages I make in  into your code. 
Mohan Raj 33Mohan Raj 33
@Søren Landschultz Hi, Sir I have same problem as I am also now try to get a two date/time field's difference in the result field is number field in the result is in hour I have a doubt if in that the two date/time fields itself I am using one is NOW() so Please help me to solve this issue.Thank You Mohan
 
Søren LandschultzSøren Landschultz
@Mohan Raj 33: If you want to calculate the hours elapsed between NOW and another Date/Time field, your formula should be:
(NOW() - DateTimeField)  *  24