How can createddate be larger than lastmodifieddate?

181    Asked by Aashishchaursiya in Salesforce , Asked on Apr 26, 2023

When a record is created and trigger executes (after insert)- updating a field, I want to calculate the time difference between the last modified date and the created date in seconds. If it's greater than 10 seconds, update the field as true else false. Can someone tell how to calculate in seconds?

Answered by Aashna Saito

The answer to your question - How can createddate be larger than lastmodifieddate is -


createdDate-LastModifiedDate
Returns the difference in the number of days - it's like yesterday- today - 1
If you multiply by 24 (24 hours a day ) returns the value in hours
then by 60 (60 minutes) returns the value in minutes
then again another 60 (60 seconds) returns the value in seconds
Difference in seconds
(createdDate-lastModifiedDate)*24*60*60


Your Answer

Interviews

Parent Categories