1

Very new to SOQL. Looking to write a query (to be used in Apex Data Loader) that pulls records with a CreatedDate <= 14 days ago. None of the predefined date options (LAST_N_DAYS, etc.) seem to cover what I'm looking for. I'm guessing/hoping there is something similar to DATEADD(D, -14, DATE()) that can dynamically calculate 14 days ago, so that the criteria would ultimately look like CreatedDate <= DATEADD(D, -14, DATE()).

Thanks in advance!

Jake
  • 893
  • 2
  • 9
  • 17

1 Answers1

2

There isn't any Date Add. However looking at your criteria the LAST_N_DAYS builtin should do the trick for you

Lets say I want to select Data that is older than 14 days ago (including that day) I would do Select Id, CreatedDate from Account where CreatedDate <= LAST_N_DAYS:14 if I need the opposite ie data created in the last 14 days Select Id, CreatedDate from Account where CreatedDate >= LAST_N_DAYS:14

thegogz
  • 654
  • 6
  • 14
  • Thank you! All of the documentation I'd found used the equal operator with respect to LAST_N_DAYS (trying to capture the time X days back moving forward); I hadn't considered just changing the operator. – Jake Sep 25 '15 at 14:51