Home SALESFORCE filter criterion for field ‘createdDate’ must be of type dateTime and should not be enclosed in quotes in SOQL

filter criterion for field ‘createdDate’ must be of type dateTime and should not be enclosed in quotes in SOQL

CreatedDate between two specific dates, but getting errors like when sending my query. For example, the query below should be giving a list of Contact from 07/20 to 07/25.

SELECT Id FROM Contact WHERE  CreatedDate >= 2014-07-20  AND  CreatedDate <= 2014-07-25

but got the Error like Below:
value of filter criterion for field ‘CreatedDate’ must be of type dateTime and should not be enclosed in quotes
here is the Answer:
CreatedDate is a Datetime field, so we need to use like following way:

Syntax: YYYY-MM-DDThh:mm:ssZ (optionally with timezones)

SELECT Id FROM Contact WHERE  CreatedDate >= 2014-07-20T00:00:00Z  AND  CreatedDate <= 2014-07-20T23:59:59Z

SELECT Id FROM Contact WHERE CreatedDate >= 2014-07-20T01:02:03Z

SELECT id, CreatedDate FROM Contact where CreatedDate < 2014-07-25T00:00:00Z.

You may also like

Leave a Comment