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
kavya mareedukavya mareedu 

Help me in labeling the feilds more relevantly

I want to collect past 5 years data for a scenerio, let's say data from 2019,2018,2017,2016,2015.

I want to label 2019 data as Current_Year
2018 as Previous_Year
2017,2016,2015 as what??? Do you guys have any suggestion for me.

I don't want to hard code the years in number

Any suggestions please??????????????
Raj VakatiRaj Vakati
Use LAST_N_YEARS:n  like below 

Starts 00:00:00 on January 1 of the previous year and continues through the end of December 31 of the previous nth year.

 
SELECT Id FROM Opportunity WHERE CloseDate > LAST_N_YEARS:5

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm