0

My SOQL Query is giving unknown parsing error. Whats the issue?

Select id, Account_Name__C, Account_Name__r.Email__c from QOACH_Conversion__c where LAU_CSAT_rating_of_IQOS_Coach__c= null AND CreatedDate= Date.today().addDays(-7)

  • Are you interested in the day seven days ago, or the last seven days? – sfdcfox Jun 27 at 2:11
  • day seven days ago – Marc Jun 27 at 2:15
  • Apex code or an API call? Sorry, I should have asked that, too. – sfdcfox Jun 27 at 2:19
  • I am bulding the query in workbench/Query Editor. I cannot use apex – Marc Jun 27 at 2:21
3

The syntax you've quoted is only for Apex code (and needs a : prefixing it). There's also no such thing as the "between" operator in SOQL. As an alternative, you can use two date filters:

SELECT ... FROM ... WHERE ... AND CreatedDate = LAST_N_DAYS:7 AND CreatedDate != LAST_N_DAYS:6

Or, the apparently undocumented N_DAYS_AGO filter:

SELECT ... FROM ... WHERE ... AND CreatedDate = N_DAYS_AGO:7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.