# REST API Date format

**URL:** <https://www.epiusers.help/t/rest-api-date-format/84133>\
**Category:** Epicor ERP 10\
**Tags:** rest-api\
**Created:** [November 1, 2021, 10:35pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133 "2021-11-01T22:35:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arul](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@Arul](https://www.epiusers.help/u/Arul)\
**Post date:** [November 1, 2021, 10:35pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/1 "2021-11-01T22:35:27Z")

</div>

I am having an issue with a date conversion error when updating the date calling the updatable BAQ service through Postman. Any help is much appreciated.

“UD04\_Date20”: “2021-10-28T00:00:00+11:00”

{  
“HttpStatus”: 500,  
“ReasonPhrase”: “REST API Exception”,  
“ErrorMessage”: “Unable to cast object of type ‘System.DateTimeOffset’ to type ‘System.IConvertible’.Couldn’t store \<28/10/2021 12:00:00 AM +11:00\> in UD04\_Date20 Column. Expected type is DateTime.”,  
“ErrorType”: “System.ArgumentException”,  
“CorrelationId”: “6a50fc9e-c242-4e3a-879f-cdbe7846170e”  
}

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [November 1, 2021, 10:51pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/2 "2021-11-01T22:51:57Z")

</div>

Why are you putting +11:00 at the end of your time?

---

<div class="post-metadata">

**Author:** ![Arul](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@Arul](https://www.epiusers.help/u/Arul)\
**Post date:** [November 1, 2021, 11:13pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/3 "2021-11-01T23:13:52Z")

</div>

I tried without +11:00 like “UD04\_Date20”: “2021-10-28T01:01:00” and getting below error.

{  
“error”: {  
“code”: “”,  
“message”: “The request is invalid.”,  
“innererror”: {  
“message”: “patch : Cannot convert the literal ‘2021-10-28T01:01:00’ to the expected type ‘Edm.DateTimeOffset’.\r\n”,  
“type”: “”,  
“stacktrace”: “”  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![24x7](https://www.epiusers.help/user_avatar/www.epiusers.help/24x7/32/30637_2.png) [@24x7](https://www.epiusers.help/u/24x7)\
**Post date:** [November 4, 2021, 4:26am UTC](https://www.epiusers.help/t/rest-api-date-format/84133/4 "2021-11-04T04:26:37Z")

</div>

I can see the saved data is in the following format: 2018-06-05 12:09:59.957  
Could you try pushing your data in this shape ?

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [November 4, 2021, 1:15pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/5 "2021-11-04T13:15:23Z")

</div>

Is your Ubaq working in the UI? When you send in something via JSON the date with be a string. That means that you should be sending in the same exact string as what you type into your UBAQ. Is that what you are doing?

---

<div class="post-metadata">

**Author:** ![Arul](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@Arul](https://www.epiusers.help/u/Arul)\
**Post date:** [November 14, 2021, 7:59am UTC](https://www.epiusers.help/t/rest-api-date-format/84133/6 "2021-11-14T07:59:33Z")

</div>

> [@Arul](#):
>
> }

It didn’t work

---

<div class="post-metadata">

**Author:** ![Arul](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@Arul](https://www.epiusers.help/u/Arul)\
**Post date:** [November 14, 2021, 8:02am UTC](https://www.epiusers.help/t/rest-api-date-format/84133/7 "2021-11-14T08:02:46Z")

</div>

UBaq is working in the UI. Date format in the UI is dd/mm/yyyy.

---

<div class="post-metadata">

**Author:** ![SteveFossey](https://www.epiusers.help/user_avatar/www.epiusers.help/stevefossey/32/19220_2.png) [@SteveFossey](https://www.epiusers.help/u/SteveFossey)\
**Post date:** [November 14, 2021, 12:24pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/8 "2021-11-14T12:24:19Z")

</div>

you might have to put a trace on the UBAQ. What it shows in the UI isn’t necessarily what it passes in.

---

<div class="post-metadata">

**Author:** ![kananga](https://www.epiusers.help/user_avatar/www.epiusers.help/kananga/32/80812_2.png) [@kananga](https://www.epiusers.help/u/kananga)\
**Post date:** [November 15, 2021, 9:08pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/9 "2021-11-15T21:08:23Z")

</div>

UD date columns are just SQL `date` format. SQL is typically happy converting standard variants of YYYYMMDD. `select cast('20210101' as date)` parses out to January 1st, 2021. Same story for ‘2021-01-01’, and ‘2021/01/01’.

Passing in datetime equivalent strings also works for `cast()` in SQL. `select cast('20200101 01:01:01.001' as date)` also parses to January 1st, 2021. It is generally better to trim date strings back to just the date portion though.

That’s not acknowledging what kind of shenanigans the REST API intermediary gets up to with the values you give it. I haven’t caught it tinkering with the values I give it, maybe a token sanity check here and there, but for the most part it acts like a naive conveyor belt.

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [November 17, 2021, 7:41pm UTC](https://www.epiusers.help/t/rest-api-date-format/84133/10 "2021-11-17T19:41:14Z")

</div>

Try this.

“UD04\_Date20”: 2021-10-28T00:00:000Z
