In dynamic SOQL (where the SOQL is a string) dotted expressions are not supported for bind variables (that follow the
Best approach is to use static SOQL instead and that way you also get more syntax checking done for you. So:
Contact contacts = [
WHERE SyncToMarketo__c = true
AND LastModifiedDate >= :Date.today().addDays(-1)
If you have a reason to use dynamic SOQL, then this should work providing the query is executed where
d is still in scope:
Date d = Date.today().addDays(-1)
String q = ''
+ ' SELECT Id'
+ ' FROM Contact'
+ ' WHERE SyncToMarketo__c = true'
+ ' AND LastModifiedDate >= :d';
Contact contacts = (Contact) Database.query(q);