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
Avi123Avi123 

Calculate Age of opportunity at each stage

Hello,

 

Can someone help me in creating a formula to find the age of an opportunity at each stage.

 

Thanks in advance

IspitaIspita

Hi Avi123,

The best solution for your requirment would be to have n fields (in case if you have n stages) for capturing the time for which the opportunity was in each stage.

You could use a trigger to capture the time interval whenever there is a change of stage in the opportunity in the appropriate field meant for this purpose.

 

Also you can refer to the following code for finding the interval / time period between 2 dates:-

 

date startDate =   date.newInstance(2008, 1, 1);
date dueDate =    date.newInstance(2008, 1, 30);
integer numberDaysDue =    startDate.daysBetween(dueDate);

 

 Hope this helps ? If not, let me know what didn't work, or if so, please mark it solved.

GuillermoPGuillermoP

No trigger is really necessary. Just setup one Date/Time field for each stage, then setup 1 field update per D/T field you created. Have it figure (and re-fire) each time the stage is set from one to the other. Now just do a formula comparing the times between the current stage and the created date. Or setup a calculation of time between each stage?