[SalesForce] Extract year from date field

I have a custom field with date type. I want to use just the year from this date field for a calculation. I want to use to update a field value. I am unable to get only the year from the date field. I would like to get the year and subtract it by 10.

I used:
YEAR( finish_date__c) -> It gave an error

YEAR( DATE(finish_date__c) ) -> Did not work this way too.

Any idea how I can just get the year and use it in formula?

Best Answer

If you're using a date field, it would be YEAR(Field__c). However, if you're using a date/time field, you need to use DATEVALUE (e.g. YEAR(DATEVALUE(Field__c)). Finally, if you're trying to display it by itself, it needs to be a number return type. To make it back into a date, you'd have to use DATE: e.g. DATE(YEAR(DATEVALUE(Field__c)), 1, 1).

Related Topic