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

difference of two dateTime fields in minutes


I need to build a logic where i have to find the difference of two DateTime fields and should populate those with no. of days. The required elapsed time calculation should be as follows.

if the elapsed time is  0 to 47 hours and 59 minutes = 1 day. 
if the elapsed time is 48 hours to 72 hours = 2 days
if the elapsed time is 72 hours to 96 hours = 3 days and so on..

For this, I have written a trigger with below logic, 

trigger TurnAroundTime on Merchandise__c (Before update) 
    for(Merchandise__c Mer : Trigger.New)
       If(Mer.start__c != null)
            If(Mer.Final__c != null)
                System.debug('Final Check has done');
                Long minutes = (Mer.Final__c.getTime() - Mer.start__c.getTime())/(1000*60) ;
                system.debug('************minutes: '+minutes) ;
                    If(minutes < 2879)
                        Mer.TAT__c = 1 ;
                    else if(minutes > 2879)
                        Mer.TAT__c = minutes/(60*24) ;
                        Mer.TAT__c = 0;
                    system.debug('*******TAT : ' +Mer.TAT__c) ;

But the problem is i need to write this trigger on an object is which is installed by managed package(from AppExchange), but we dont have priviliges to create trigger on that managed package object. So i thought of writing a workflow or formula field for the same functionality, but there were no available dateTime functions in formula-field to get this done. 

Is there any way to achieve this through formula-field ?? or any way to create a trigger on appExchange object which is locked for users ??
Looking into it

Did you try Process Builder, it really can do lot of things i am not sure it can work with managed packaged object or not give it a try mean while we ae searching for your soluction