salesforce last_n_years not include current year code example
Example 1: soql last week
Select * from case where WHERE CreatedDate = LAST_N_DAYS:30
Example 2: soql last year
delete [SELECT Id FROM Opportunity WHERE CreatedDate = LAST_YEAR];
Select * from case where WHERE CreatedDate = LAST_N_DAYS:30
delete [SELECT Id FROM Opportunity WHERE CreatedDate = LAST_YEAR];