« Offset Pagination Coming to SOQL | Main | Executing Anonymous Apex Inside Eclipse »

Select all records created before/after ___ with SOQL

I get this question from time to time. Often times we want to look at all records that were created or last updated before/after a certain date. Here is a quick example of how to select all the contacts created after a certain date:

SELECT Id, FirstName, LastName from Contact where CreatedDate >= 2012-05-07T00:00:00Z

Yes, you have to write the date in that format. And no, don't put the date in quotes.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
All HTML will be escaped. Hyperlinks will be created for URLs automatically.