have to query the record of the article which is created on past 2 day alone.tried using this SOQL but its not returning the correct values.

SELECT id, CreatedDate, CreatedById, Flag_It__c, Knowledge_Article_Lookup__r.Title 
FROM Knowledge_FeedBack__c 
WHERE CreatedDate = Last_N_Days:2 AND CreatedDate < Last_N_Days:3
  • If you remove the AND CreatedDate < Last_N_Days:3, it should work. Feb 8, 2020 at 14:05

1 Answer 1


You just need to get rid of AND CreatedDate < LAST_N_DAYS:3. CreatedDate = LAST_N_DAYS:2 should be enough for your requirement.

Here is the documentation for your reference: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm

  • thanks for your help.. i have followed your steps. the result I got.. the query resulted by pulling all the records of last 2 days, but my actual requirement is to get the record of past 2nd(day before yesterday's record only) date only.
    – Surendhar
    Feb 8, 2020 at 5:11
  • you can add AND CreatedDate != LAST_N_DAYS:1 on a where clause. It should works. Feb 10, 2020 at 6:24

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.