This week SugarCRM Gold Partner EnableIT SugarUK‘s Mike Gee shows how you can use calculated fields to count the number of days between two specified dates.
One of the questions I was asked most as a result of my previous post Sugar Tip – Creating a calculated field to count days until a date was “How can I calculate the number of days between two date fields?”
As a result, here is the answer:
In order to achieve the calculation, you need to already have two date fields in your SugarCRM system. If you need to create these, they should be done in the Studio prior to creating the calculated field.
Create a new field in the Studio in the same module as the two date fields using an Integer field, clicking the “Calculated” tick-box and in the Formula Editor use the following calculation:
where $datefieldA is the earliest date and $datefieldB is the later date.
e.g. To calculate the difference between the date a record was created and the last time it was modified, you would put the datecreated field string in$datefieldA and the datemodified string in $datefieldB.
This tip was originally posted on the EnableIT SugarUK Blogs where you can find a whole host of other useful SugarCRM tips.