How to resolve the error of salesforce date literals?

412    Asked by diashrinidhi in Salesforce , Asked on Apr 28, 2023

The SF doc explains how to put a Datetime query in a SOQL query. SELECT Id FROM Account WHERE CreatedDate > 2005-10-08T01:02:03Z I need to just put in a date for this query. Something like: SELECT Id FROM Account WHERE CreatedDate > 2005-10-08

But that throws an error.

Answered by Elvera Peasley

To resolve the error of salesforce date literals -

  • 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
WHERE CreatedDate > YESTERDAY
For more on date formats and more literal values see,

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm


Your Answer

Interviews

Parent Categories