# How to set 'date' variable with correct format from xml

**URL:** <https://community.postman.com/t/how-to-set-date-variable-with-correct-format-from-xml/10617>\
**Category:** Help Hub\
**Tags:** tests, variables\
**Created:** [February 6, 2020, 10:59am UTC](https://community.postman.com/t/how-to-set-date-variable-with-correct-format-from-xml/10617 "2020-02-06T10:59:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matjas\_22](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@Matjas\_22](https://community.postman.com/u/Matjas_22)\
**Post date:** [February 6, 2020, 10:59am UTC](https://community.postman.com/t/how-to-set-date-variable-with-correct-format-from-xml/10617/1 "2020-02-06T10:59:06Z")

</div>

Hi,  
I have this kind of response in xml:

> \<soapenv:Envelope xmlns"\>  
> soapenv:Header  
> \<work:WorkContext \</work:WorkContext\>  
> \</soapenv:Header\>  
> soapenv:Body  
> \<InvokeSBSEventRs xmlns="\>  
> GET\_OPEN\_DATE  
>   
> 06-02-2020 00:00:00  
>   
>   
> \</soapenv:Body\>  
> \</soapenv:Envelope\>

I would like to get only date - 06-02-2020 from this response

1. If i’m using this kind of script:  
var jsonData = xml2Json(responseBody);  
console.log(jsonData);  
var date = jsonData[‘soapenv:Envelope’][‘soapenv:Body’].InvokeSBSEventRs.Parameters.Parameter;

console.log(date);  
pm.globals.set(“dateOfEnv”,JSON.stringify(date)) ;

as a variable i have whole text  
{“\_”:“06-02-2020 00:00:00”,“$”:{“name”:“OPEN\_DATE”,“type”:“oracle.jbo.domain.Date”,“format”:“dd-MM-yyyy HH:mm:ss”}}

1. If i’m using:  
let res = xml2Json(pm.response.text());  
pm.globals.set(“dateOfEnv”,\_.get(res,‘InvokeSBSEventRs.Parameters.Parameter’));

then as a result - null

Will be thankful for help

---

<div class="post-metadata">

**Author:** ![Matjas\_22](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@Matjas\_22](https://community.postman.com/u/Matjas_22)\
**Post date:** [February 6, 2020, 2:16pm UTC](https://community.postman.com/t/how-to-set-date-variable-with-correct-format-from-xml/10617/2 "2020-02-06T14:16:45Z")

</div>

Ok i found answer 🙂

pm.globals.set(“dateOfEnv”,JSON.stringify(date.\_)) ; → return only date
