1

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
2016-07-31T04:17:54
2016-07-31T04:17:54Z
2016-07-31T04:17:54.000
2016-07-31T04:17:54.000Z
2016-07-31T04:17:54.000+1:00
2016-07-31 04:17:54

What is I am missing over here?

  • Try 2016-07-31T04:17:54Z. – Adrian Larson Jul 29 '16 at 13:37
  • @AdrianLarson- Tried and getting this error value of filter criterion for field 'CloseDate' must be of type date and should not be enclosed in quotes – Samuel Alexander Jul 29 '16 at 13:39
  • If you include time don't use DAY_ONLY. Otherwise drop everything before the T. – Adrian Larson Jul 29 '16 at 13:40
  • @AdrianLarson - Tried both. Still getting the same error :( – Samuel Alexander Jul 29 '16 at 13:50
3

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.

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

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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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