I have a custom field whose data type is "Date". I would like to use this field in a formula editor. I want to get only the year value from the date field( field api name is pres_date__c). When I used the following it gave me a error that-

pres_date__c may not be used in this type of formula

i) YEAR(pres_date__c )
ii) YEAR(DATE(pres_date__c))

Both of the above did not give me an year value. Any suggestion how can I just get the year from date?

  • try YEAR(DATEVALUE(pres_date__c))
    – Ratan Paul
    Jan 20, 2016 at 16:36
  • It gave me the same error..
    – SfdcBat
    Jan 20, 2016 at 16:39
  • Yes I am sure the data type is a date
    – SfdcBat
    Jan 20, 2016 at 16:49
  • what is your return type of formula
    – Prajith
    Jan 20, 2016 at 16:56
  • Yes your formula field return type should be integer
    – Ratan Paul
    Jan 20, 2016 at 16:59

1 Answer 1


Here's what I tested on Contact:

Formula return type: Text

TEXT(YEAR( Birthdate ))

That works.

I'd check that you really have a date field.

  • Can I use this TEXT(YEAR( Birthdate )) in a a field whose return type is Text ( is it possible to use this in the formula editor of text data type field)
    – SfdcBat
    Jan 20, 2016 at 17:10
  • Yes, that's how I did it in my test. If you use number Salesforce will try to be helpful and display "2,016". Probably not what you want.
    – powlo
    Jan 22, 2016 at 10:09
  • I had to use a workflow field update for this. It did not work when using in normal text field-> default value-> formula.
    – SfdcBat
    Jan 22, 2016 at 18:17
  • There's a difference between creating a text field with a formula default value, and a formula field that contains text. A formula in a default value can't know about any other values for that record, since they don't yet exist. Therefore the formula editor only gives you access to global values.
    – powlo
    Jan 25, 2016 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.