To make an SQL query like:
SELECT id FROM Account WHERE LastActivityDate = 30_DAYS_AGO
You can calculate the date in apex and then bind it into your query.
Are you interested in learning Salesforce from scratch! Have a look at this interesting video on Salesforce provided by Intellipaat:
As shown in Example:
date d = system.today().addDays(-30); Account [] acc= [select id from account where createdDate = :d];
Or, you can go ahead and use:
SELECT id FROM Account WHERE LastActivityDate = LAST_N_DAYS:30
LAST_N_DAYS is a sytax which is used to find out the activity in the last N days (here, N = 30)
To learn in-depth about Workflow in Salesforce, sign up for industry-based Salesforce Training!