In this Salesforce Tutorial, we will learn the formula to extract Year from Date in Salesforce. Moreover, we will go through the steps using which we can extract Year from Date Field in Salesforce Lightning and Salesforce Classic.
In Salesforce, there are many scenarios where we need to extract the year from the date value in Salesforce, such as age calculation, event planning so that we don’t get messed with holidays, historical, financial analysis, and to determine the validity and expiration of documents, etc.
And, In all these situations, we need to extract the year from the date in Salesforce. So, If you want to explore How to Extract Year from Date in Salesforce Lightning and Classic Edition, you have come to the right place.
The following are the topics that we will cover in this Salesforce Tutorial:
- Extract Year from Date using Advance Formula
- How to extract Year from Date in Salesforce Lightning
- How to extract Year from Date in Salesforce Classic
Extract Year from Date using Advance Formula
In Salesforce, to extract the year from the date value, we use the Salesforce Year() function.
Here is the syntax to extract Year from Date in Salesforce:
YEAR(date_field)
If, you want to learn in detail about YEAR() function, click Date Formula Functions in Salesforce.
How to extract Year from Date in Salesforce Lightning
Here, are the steps to extract Year from Date using the Advance Formula in Salesforce Lightning.
Step 1: Navigate to Salesforce Setup, by clicking on the Setup icon on the upper right side of the page.
Step 2: On the left side of the menu, click on Object Manager.

Step 3: Search for the object to which we want to extract the year from the date field. Here, I select the Products object from the list of objects.

Step 4: Click on Fields & Relationships.
Step 5: Then, click on New.

Step 6: Choose the Formula as the field type.
Step 7: To continue, click Next.

Step 8: Enter a Field Label for the formula, and the Field Name will be automatically populated. Here, I enter Field Label as the Expiry Year.
Step 9: Choose Text as the Formula Return Type because by default the YEAR function displays the result in number system format i.e separate number places with commas. Then click Next.

Step 10: Enter the Extract Year from Date formula in the Advance Formula editor. Here, is the formula:
TEXT(YEAR(Product_Expiry_Date__c))
- In this formula, we fetch out the year from the date field called “Product_Expiry_Date__c” using the YEAR Salesforce function. But by default, the YEAR function returns the result in a number.
- To get the result in the text format, we will use the TEXT function with the YEAR function.
Step 11: Click Check Syntax to make sure the formula is correct.
Step 12: We can add the Description and Help Text as options, and we can also state how you want to handle the blank field.
Step 13: After that, click Next.

Step 14: Select the appropriate field Level Security and to make it visible to everyone, here we select the Visible checkbox.
Step 15: Select Next.

Step 16: Choose the Page Layout Name, for whom we want to add the formula field.
Step 17: To save the formula field, click Save.

We can use the formula field once we’ve created it. Let’s look at an example:
- Create a new product using the Product Expiry Date value by opening the Products object and saving it.
- After that, click on the Details section, and here the Expiry Year field will appear with the extracted year from the date value.

As a result, we now know how to use Salesforce Lightning’s advanced formula to extract the Year from the Date field. Next, we’ll look at how to use Salesforce Classic’s advance formula to extract the Year from the Date field.
Read Add Days to Date in Salesforce Formula
How to extract Year from Date in Salesforce Classic
Here, are the steps to extract Year from Date using the Advance Formula in Salesforce Classic.
Step 1: From the Salesforce Lightning to open your Salesforce Classic edition. Click on Avtar and click Switch to Salesforce Classic.

Step 2: Click on the Setup option.

Step 3: Scroll down to the Build section. Then under Customize, select the object for whom we want to extract the Year from the Date. Here, I choose the Accounts from the object list.
Step 4: Click on the dropdown menu and select Fields.

Step 5: As you scroll down the page, click on the New button under Custom Fields & Relationships.

Step 6: Select the Formula as the field type.
Step 7: Click Next to proceed.

Step 8: Enter a Field Label for the formula, and the Field Name will be automatically populated. Here, I enter Field Label as the Signed Year.
Step 9: Choose Number as the Formula Return Type because the YEAR function displays the output by default in number system format, which separates number places with commas, then click Next.

Step 10: The Advance Formula editor extracts the Year from the Date formula. The formula is as follows:
YEAR(CompanySigned)
- In this formula, we use the YEAR Salesforce function to retrieve the year from the date column “CompanySigned”. However, the YEAR function by default returns the result as a number.
Step 11: To verify that the formula is valid, click Check Syntax.
Step 12: We can specify how you want to handle the empty field and include the Description and Help Text optionally.
Step 13: Then, click Next.

Step 14: Choose the appropriate Field’s Level Security, and then check the box Visible to make it visible to all.
Step 15: Click Next.

Step 16: Choose the Page Layout Name for which the formula field is to be added.
Step 17: Click Save to save the formula field.

Once we’ve defined the formula field, we may use it. Let’s explore an example:
- Create a new Contract with the ContractSigned field value by opening the Contracts object and saving it.
- After that, click on the Details section, and here the Company Signed Year field will appear with the extracted year date value from the date value.

In a conclusion, we now understand how to extract the Year from Date using Salesforce Classic’s advanced formula.
Also, Read:
Conclusion
In conclusion, we have learned the advance salesforce formula to extract Year from Date.
Moreover, we have learned that both Salesforce Classic and Salesforce Lightning provide a simple procedure to Extract Year from the Salesforce Date field.
In addition to this, the following are the topics that we have discussed:
- Extract Year from Date using Advance Formula
- How to extract Year from Date in Salesforce Lightning
- How to extract Year from Date in Salesforce Classic
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.