soql NEXT_N_DAYS LAST_N_DAYS 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];