Is there anyway I can use a variable value for LAST_N_DAYS. For example, I am trying to do something like:
Integer lastDays = 7; //... //... List<Opportunity> opportunities = [SELECT OwnerId, Amount, Probability FROM OPPORTUNITY where Amount > 0 and LastModifiedDate < LAST_N_DAYS:lastDays];
But I get:
expecting a number, found 'lastDays'
Wow, that's an interesting one! I doubt it's allowed though (at least without having to use Dynamic SOQL).
You can always do this instead: