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
SeanCoSeanCo 

Formula to calculate total hours

Hi, I am fairly new to customizing SalesForce and trying to figure out the best approach (formula or trigger) to the following problem:
 
We have a custom object called 'Contract' that has a lookup field to 'Account'.  One of the fields on the 'Contract' custom object will need to calculate (sum) all case hours where Case Account Name value is same as Contract Account Name value.  In addition to the condition just mentioned we only need case hours that fall in between the contract start date and end date (fields on the custom object).  
 
Can this be achieved using a formula?  I almost got it worked out using SOQL but ran into some limitations since you cannot do field comparisons.  Thanks for any help you might be able to provide!  
Best Answer chosen by Admin (Salesforce Developers) 
SeanCoSeanCo

This was outside of the scope of a formula.  We created a custom APEX trigger for this.