[SalesForce] Datetime representation in SOQL executed via REST API

I am trying to execute below SOQL using Salesforce REST API using Postman

services/data/v36.0/query?q=Select Id from Opportunity  where CloseDate < 2016-07-31T04:17:54

But I am getting below exception

    "message": "\nDAY_ONLY(CloseDate) < 2016-07-31T04:17:54\n                                        ^\nERROR at Row:1:Column:75\nline 1:75 no viable alternative at character '<EOF>'",
    "errorCode": "MALFORMED_QUERY"

I don't get what is wrong with the query.

I referred How to Apply a DateTime Filter when using SOQL via REST API and used DAY_ONLY function like below. But still got the same exception

services/data/v36.0/query?q=Select Id from Opportunity  where DAY_ONLY(CloseDate) < 2016-07-31T04:17:54

I've tried using the below formats of date, but of no use.

2016-07-31 04:17:54

What is I am missing over here?

Best Answer

The CloseDate field is of the Date type. That means you should not include a time component in your filter value. This query works for me in the Developer Workbench. Should be the same for you in Postman, I'd think.


Specifically, the date format is 2016-07-31.

Related Topic