This question already has an answer here:

The SF doc explains how to put a Datetime query in a SOQL query.

FROM Account
WHERE CreatedDate > 2005-10-08T01:02:03Z

I need to just put in a date for this query. Something like:

FROM Account
WHERE CreatedDate > 2005-10-08

But that throws an error. Any ideas?

marked as duplicate by Ralph Callaway, Daniel Blackhall, eyescream, Saariko Feb 28 '13 at 8:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


CreatedDate is a datetime field so I guess you would need to specify the time component.

Can you do something like where you just append the time portion to be 12 am by default.

WHERE CreatedDate > 2005-10-08T00:00:00Z

Or you can use Date Literals like


For more on date formats and more literal values see,


  • 1
    The advice in another answer to use "DAY_ONLY()" is the correct answer. Otherwise a developer would have to write, "where createddate >= yyyy-mm-ddT00:00:z and createddate < yyyy-mm-ddT00:00:00z" where the second date is actually the day after the first (or some similar bounded comparison). If had had to choose (and I just did today), I would use DAY_ONLY(). developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/… – tggagne Nov 2 '18 at 13:18

To filter a SOQL query on a datetime field with a day value, use the DAY_ONLY SOQL operator.

FROM Account
WHERE DAY_ONLY(CreatedDate) > 2005-10-08

You can bind a date variable into the SOQL Query as well, but the results might not be what you expect as there the date variable would be cast into a DateTime type at run time.


If you want to avoid date manipulation with Apex, you could also create a custom date formula field and query off that field. Your formula would look like this:


Then just query off your custom field.

Let me know if you have any questions.

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