function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Administrator 167Administrator 167 

API REST for XX/updated between 2 datetime

Hellow,
I'm trying to get Get a List of Updated Records Within a Given Timeframe, as explained here:
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_updated.htm

Here is my API:
/services/data/v49.0/sobjects/MyObject/updated/?start=2020-06-07&end=2020-07-07

I tried with many date formats (YYMMMMDD-xx:xx:xx etc.), yet I still get the following error:
INVALID_DATE_FORMAT
message: Error parsing the 'start' date string. This operation requires properly formatted 'start' and 'end' date/time parameters to be specified. Please consult the documentation for the format of these date/time fields.

Can anyone please tell me where I am wrong in my API syntax ?
Thank you,
Best Answer chosen by Administrator 167
VinayVinay (Salesforce Developers) 
Try below format.
/services/data/v49.0/sobjects/MyObject/updated/?start=2020-10-21T01:02:03Z&end=2020-11-12T01:02:03Z

Note: 'startDate' cannot be more than 30 days ago

Hope this helps..

All Answers

VinayVinay (Salesforce Developers) 
Datetime variables in SOQL take the format YYYY-MM-DDTHH:MM: SSZ

That's a "T" between the date and the time and a "Z" at the end.  Date variables in SOQL take the format YYYY-MM-DD.

Check below date formats.

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

Thanks,
Administrator 167Administrator 167
Hello, thanks, 
Yet you do not answer the question: why is the following API statement false ?
/services/data/v49.0/sobjects/MyObject/updated/?start=2020-06-07&end=2020-07-07
 
VinayVinay (Salesforce Developers) 
Try below format.
/services/data/v49.0/sobjects/MyObject/updated/?start=2020-10-21T01:02:03Z&end=2020-11-12T01:02:03Z

Note: 'startDate' cannot be more than 30 days ago

Hope this helps..
This was selected as the best answer