Get the time elapsed in Email-To-Case #inSalesforce

Get the time elapsed in Email-To-Case #inSalesforce


Get the difference between Case Creation Date and Email Message Date

try using:

for (EmailMessage em : [SELECT Id, MessageDate, Parent.CreatedDate FROM EmailMessage WHERE CreatedDate = TODAY AND MessageIdentifier != null AND Parent.CreatedDate = TODAY]) {
    Long CaseCreated = em.Parent.CreatedDate.getTime();
    Long CaseActuallyCreated = em.MessageDate.getTime();
    System.debug('Elapsed time in Seconds ' + (CaseCreated - CaseActuallyCreated) / 1000
    );
}

Comments