I'm trying to delete the records of a particular object which have not been modified in last 30 days. For this I have my batch Apex set up but just not been able to build the query.

Query written so far:

Select id from XYZ__c where SystemModStamp >= LAST_N_DAYS:3 OR LastModifiedDate

1 Answer 1


I believe you have the condition in reverse, it should be something like

Select id from XYZ__c where SystemModStamp < LAST_N_DAYS:30

You might have to play with the number to include/exclude those with exactly 30 days of difference. Also feel free to add the LastModifiedDate if you want

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .