I am trying to get a list of reports that need to be deleted from Salesforce. I have created a report of reports with the below criteria.
The report seems fairly accurate and I am trying to get the same list of reports via SOQL and I have constructed the SOQL as below.
SELECT Id, Name, DeveloperName, FolderName, LastRunDate from Report WHERE LastRunDate != LAST_N_MONTHS:6 AND (NOT FolderName LIKE '%Marketing%') AND (NOT FolderName LIKE '%Sys Admin%') AND (NOT FolderName LIKE '%Marketing%')
Unfortunately, the SOQL results doesn't seem to be accurate. When I compared the Report Id from the report spread sheet and the SOQL resultset, there are several differences. The report shows the number of reports to be cleaned up as 5214 whereas the SOQL shows 5216 reports. When I checked the differences, I could see that the SOQL has pulled some reports that were ran just a few days ago. Below is an example.
My understanding is that if I include the condition LastRunDate != LAST_N_MONTHS:6, the SOQL results should not include any reports that were ran in the last six months.
Am I missing something?