How do I make a SOQL query like this?
SELECT id FROM Account WHERE LastActivityDate = 30_DAYS_AGO
This produces an error:
MALFORMED_QUERY:
Account WHERE LastActivityDate = 30_DAYS_AGO
^
SELECT id FROM Account WHERE LastActivityDate = LAST_N_DAYS:30
As you're doing this from apex, you can calculate the date in apex, then bind that into your query, e.g.
date d = system.today().addDays(-30);
Account [] acc= [select id from account where createdDate = :d];
Select Id from Account Where LastActivityDate = N_DAYS_AGO:30
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With