# Date conversion from SAP JSON

**URL:** <https://community.postman.com/t/date-conversion-from-sap-json/24746>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [June 10, 2021, 1:02pm UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746 "2021-06-10T13:02:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrienbouygues](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@adrienbouygues](https://community.postman.com/u/adrienbouygues)\
**Post date:** [June 10, 2021, 1:02pm UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/1 "2021-06-10T13:02:44Z")

</div>

_My question_:

how to convert in a test a date retrived from SAP from Unix Timestamp to iso date.

_Details (like screenshots)_:

Hello to all.

i would like to test if a date retrived from SAP is the same as the one i wanted. i read data with a get (JSON) but the date is retrived in Unix timesamp format. So i started to find a formula to convert it. In excel the formula is (date in unix/86400000)+DATE(1970;1;1) but i would like to do it directly in Postman.

my issue is that SAP retrived me the data like this:

![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/2/8271fa726cf81c611045b39a11c8b0f3193bddc9.png)

how can i get just 1516147200000 to convert it or is there a function to convert directly the date ??

i tried to work from this with:

![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/7/573f4842768ba2dfe1ff39f219181d723e41ed53.png)

work well for the date of the day…

thank you in advance for your help.

---

<div class="post-metadata">

**Author:** ![taehoshino](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/taehoshino/32/6608_2.png) [@taehoshino](https://community.postman.com/u/taehoshino)\
**Post date:** [June 11, 2021, 2:59am UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/2 "2021-06-11T02:59:58Z")

</div>

Hey @adrienbouygues 👋 Welcome to the Postman Community 🎉

Would the following script work?

```auto
const moment = require('moment')
const isoDate = moment(1516147200000).format('YYYY-MM-DD')

```

Hope this helps, but please do let me know if this is not what you are after 🙂

---

<div class="post-metadata">

**Author:** ![adrienbouygues](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@adrienbouygues](https://community.postman.com/u/adrienbouygues)\
**Post date:** [June 11, 2021, 8:33am UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/3 "2021-06-11T08:33:17Z")

</div>

Hello @taehoshino thank you very much!!

The following script is working well for the conversion thank you very much.  
My other issue is that my date is retrived this way:

“date”: “/Date(1528588800000)/”

do you have any idea to get directly the unix number: 1528588800000 ?

Thanks again

---

<div class="post-metadata">

**Author:** ![taehoshino](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/taehoshino/32/6608_2.png) [@taehoshino](https://community.postman.com/u/taehoshino)\
**Post date:** [June 15, 2021, 7:22am UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/4 "2021-06-15T07:22:09Z")

</div>

Hey @adrienbouygues 👋

Glad to hear that it helped!

I understand the response is JSON, correct? Then you can do something like below?

```auto
const response = pm.response.json()
const date = response.date // this is to access "date" property of JSON response
const dateTimeStamp = date.split(/\(|\)/g)[1] // this is splitting the "date" string using regular expression

```

---

<div class="post-metadata">

**Author:** ![shivanip12](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@shivanip12](https://community.postman.com/u/shivanip12)\
**Post date:** [January 2, 2022, 1:20pm UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/5 "2022-01-02T13:20:06Z")

</div>

Hello,

I have a similar issue… Few of the JSON string are in epoach format… Could you please tell me how do i convert it into DD/MM/YYYY format manually  
Adding the screenshot

 ![IMG_20220102_184942](https://us1.discourse-cdn.com/getpostman/original/2X/a/acfc2e65e1c7a0b9b6df6e5b55d1a7fc7bd4dfcb.jpeg)

---

<div class="post-metadata">

**Author:** ![adrienbouygues](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@adrienbouygues](https://community.postman.com/u/adrienbouygues)\
**Post date:** [January 3, 2022, 9:09am UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/6 "2022-01-03T09:09:42Z")

</div>

Hello @shivanip12 ,

If you would like to convert the date to a iso date you can apply this formula in excel  
=(A1/86400000)+DATE(1970;1;1). A1 is the date you get from your body response.

I hope this help.

---

<div class="post-metadata">

**Author:** ![shivanip12](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@shivanip12](https://community.postman.com/u/shivanip12)\
**Post date:** [January 4, 2022, 6:00pm UTC](https://community.postman.com/t/date-conversion-from-sap-json/24746/7 "2022-01-04T18:00:42Z")

</div>

Hello @adrienbouygues,

Thanks it helped… Is there any way we can convert it within postman?
