Extract Year From Date Using YEAR() Function in Salesforce : Bijay Kumar

Extract Year From Date Using YEAR() Function in Salesforce
by: Bijay Kumar
blow post content copied from  SalesForce FAQs
click here to view original post



### Summary of Extracting Year from Dates in Salesforce When working with Salesforce, you may need to extract just the year from a date, like the Contract Start Date. This is useful for reporting and organizing data. Salesforce provides a straightforward way to do this using the `YEAR()` function. Here's a simple overview of how to create a formula field that shows just the year of a date: 1. **Access Setup**: Go to the Gear Icon, click on Setup, then select the Object Manager tab and choose the relevant object, such as the Contract object. 2. **Create Field**: In the Fields and Relationships section, click on New to create a new field. 3. **Select Formula Type**: Choose Formula as the data type. This allows you to write a formula that extracts the year. 4. **Field Details**: Enter the Field Label and API Name. Set the Formula Return Type to Text to ensure the year is displayed correctly. 5. **Enter Formula**: In the formula editor, use the `TEXT(YEAR(StartDate))` formula, which extracts the year from the StartDate field. Validate the formula to check for errors. 6. **Field Security**: Set field-level security by selecting which profiles will have access to this new field. 7. **Configure Page Layouts**: Decide if the field should appear on the object’s page layout. Since it is primarily for reports, you can choose not to display it there. Once you've saved the formula field, you can now see the extracted year from the Contract Start Date in your Salesforce records. ### Conclusion By following these steps, you can easily create a formula field in Salesforce that extracts and displays the year from a date using the `YEAR()` function. This feature is beneficial for various tasks such as reporting and automation. ### Additional Information This process is particularly useful for age calculations, event planning, financial analysis, and managing document validity periods in Salesforce. ### Relevant Hashtags for SEO #Salesforce #DateFormulas #SalesforceYEAR #SalesforceTips #CRM #DataManagement #ReportAutomation #TechGuides #SalesforceFormula #BusinessIntelligence


When working with Salesforce date formulas, we occasionally need to extract the year from a date.

For example, suppose we are tracking the Contract Start Date on the contract object, and we want to create a date formula field that only shows the year part of that date (like 2025) for reporting or grouping purposes.

In this article, we will learn the formula to extract the year from a date using the YEAR() function in Salesforce. Moreover, we will go through the steps to extract the year from the date Field in Salesforce.

Year Function in Salesforce Formula

In Salesforce, there are many scenarios where we need to extract the year from the date value, such as age calculationevent planning, and historical and financial analysisto determine the validity and expiration of documentsetc.

And, in all these situations, we need to extract the year from the date in Salesforce. So, in Salesforce, we have the YEAR() function that we can use to extract the year from a given date.

Extract Year From Date Using Formula in Salesforce

Below, I will explain how we can extract the year from a given date so that it can be used in formulas, reports, or automation in Salesforce.

1. Go to the Gear Icon. -> Click on the Setup. -> Select the Object Manager tab. Select the Object on which you want to create the Formula Field to extract the year from the date. Here, I’m going to create a Contract Object.

    In the Contract setup, click on the Fields and Relationships to create a new field and click the New button.

    function to extract year from date

    3. In this step, we are going to use a formula to extract the year from the given date and display it on the contract object. For that, select the option Formula from the data type and click Next.

    Salesforce Formula Fields

    4. Next, provide the Field Label and API Name for the formula field. Then, since we want to display only the year of the given date without a decimal point and comma separated, in the  Formula Return Type, select Text and click on the Next button.

    How to Extract Year From Date in Salesforce

    5. In the formula editor, enter the formula below and click the Next button.

    Here, since we want to use the YEAR() function to extract the year from the date and the TEXT() function to display it in the text, we need to select the Advanced Formula.

    Then select the Function from and click the Insert Selected button to use them. Then, to add the date field from the object.

    You can see the Insert Field button as you click on it, you will see all fields from the contract object.

    TEXT(YEAR( StartDate)) 

    Provide this formula and click the Check Syntax button to confirm the formula is correct, and click the Next button.

    Salesforce Formula YEAR Function

    6. Select the Field Level Security for the formula field, and select the profiles to make the field visible for the profiles. The field will be visible for the profiles selected from the Visible column.

    After selecting the profiles, click on the Next button.

    Establish Field Level Security in Salesforce

    7. In this step, we must select the field’s visibility on the object’s page layouts. In this case, we have created the formula field for the reports so we can choose not to display it on the page layouts.

    Uncheck the checkboxes of the page layouts to prevent the field from displaying on them. After this, click on the Save button.

    Add Formula Field in Salesforce Page Layout

    We have now created the formula field that will return the year from the Contract Start Date field from the contract object.

    As you navigate to the object, you will see the formula field that you created to extract and display the year from the contract start date.

    Extract Year From Date Using YEAR() Function in Salesforce

    In this way, we can create a formula field to store the extracted year from the given date in Salesforce.

    Conclusion

    I hope you have got an idea about how to extract and display the year from a date in Salesforce using the YEAR() function so that it can be used in formulas, reports, or automation in Salesforce.

    You may like to read:

    The post Extract Year From Date Using YEAR() Function in Salesforce appeared first on SalesForce FAQs.


    August 20, 2025 at 09:48PM
    Click here for more details...

    =============================
    The original post is available in SalesForce FAQs by Bijay Kumar
    this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
    The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
    ============================

    Salesforce