RE: Rest API date+time + sorting
- When querying the lastModifiedDate or createdDate from the Rest API, how do you get the time part – it just seems to return the date. And how do you get it to show up in ISO8601 format?
For example
/services/rest/query/v1/suiteql
{
“q”:”SELECT Id, lastModifiedDate from Item”
}
returns records like
{“links”:[],”id”:”26″,”lastmodifieddate”:”7/3/2019″}
why is the lastmodifieddate not in a date/time format?
2) When trying to sort by lastModifiedDate, an error comes (but without the order by clause it works…or using some other fields in order by it works).
Example
{
“q”:”SELECT Id, lastModifiedDate from Item order by LastModifiedDate asc”
}
returns
{“type”:”https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1″,”title”:”Internal Server Error”,”status”:500,”o:errorDetails”:[{“detail”:”An unexpected error occurred. Error ID: kg79hg1f15gm0xxrqjikt”,”o:errorCode”:”UNEXPECTED_ERROR”}]}
It worked for me, you just need to change the to_char(..) as some other term. I set to datemodified instead of lastModifiedDate and it worked:
"q": "SELECT id, lastName, firstName, email, to_char(lastModifiedDate, 'yyyy-mm-dd HH24:MI:SS') as datemodified FROM employee ORDER BY to_char(lastModifiedDate, 'yyyy-mm-dd HH24:MI:SS') DESC"