1 respuesta
string query = 'select id,LastName from Contact where OldDate__c = LAST_N_DAYS:5';
This query will work for contacts whose Old date is within the last 5 days.
Since you need contacts which have Old date value as you mentioned should be 5 days older. You need to change the query to,
string query = 'select id,LastName from Where OldDate__c < LAST_N_Days:5';
This will query only those records which has Old date value older than 5 days, equal to 5 days wont be counted.