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
ShannuShannu 

Laststagechangedate on Opportutnity?

I'm attempting to create a formula field on opportunity called 'Days in Stage' that calculates the difference between the Last Stage Change Date Field and Today.
On opportunity, there is an inherent Laststagechangedate field, which is reflected in the formula field.
As a result, I devised the formula shown below.
TODAY() - Laststagechangedate and it is throwing error as below.
 Error: Incorrect parameter type for operator '-'. Expected Number, Date, received DateTime
ShannuShannu
Can someone help me here pls
VinayVinay (Salesforce Developers) 
Hi Shannu,

I dont think you would be able to use Last Stage Change Date field in formula.  Check limitation below.

https://ideas.salesforce.com/s/idea/a0B8W00000GdiXqUAJ/last-stage-change-date

However you can create new custom field and store  Last Stage Change Date field value and use custom field in formula.

Please mark as Best Answer if above information was helpful.

Thanks,
Steve :-/Steve :-/
If you read through the error message it tells you what the problem is: 

Your formula is taking a Date Value:  TODAY() and you are subracting the value from a Field:  LastStageChangeDate

You can only perform that kind of operation if the datatypes are the same, but the LastStageChangeDate  is NOT the same datatype as TODAY(), it is a DateTime Value. 

So you need to fix that by either replacing TODAY() with NOW() ,
NOW() - LastStageChangeDate

or converting  LastStageChangeDate from DateTime to Date, by using a DATEVALUE function like this   
TODAY() - DATEVALUE( LastStageChangeDate)