How can I get data from a time range? For example:

SELECT Id FROM Account WHERE CreatedDate = 3pm to 3.30pm EST
  • 6
    Just so we're all on the same page, do you mean you want to find all records created between 3pm and 3:30pm no matter which day it is, or just between 3pm and 3:30pm on one specific day? – sfdcfox Sep 4 '18 at 20:25
  • on a specific day/date – Feroze Sep 5 '18 at 23:03

Unfortunately, SOQL doesn't recognize "between", so you'll have to literally write it out:

FROM Account 
WHERE CreatedDate >= 2018-09-05T13:00:00.000-05:00 AND 
      CreatedDate <= 2018-09-05T13:30:00.000-05:00
  • Thank you, you have a script for merging bulk duplicated contacts? for some reason when the data loader restore contacts it also created duplicated and need a way to merge. Thx – Feroze Sep 6 '18 at 20:41
  • @Feroze Unfortunately, no. A successful merge script usually needs to be tailored to the situation at hand. If I were going to do it, though, I'd set up Duplicate Rules, let Salesforce figure out the duplicates for me, and then write a script to merge the duplicates. That would be a far easier solution than writing customized queries every time. – sfdcfox Sep 6 '18 at 20:50

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.