SOQL query WHERE Date = 30_days_ago?

Dave S picture Dave S · Mar 8, 2011 · Viewed 49.3k times · Source

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
                      ^

Answer

ScottW picture ScottW · Mar 28, 2011
SELECT id FROM Account WHERE LastActivityDate = LAST_N_DAYS:30