# How can I validate that a date shown in response is ordered in a desc

**URL:** <https://community.postman.com/t/how-can-i-validate-that-a-date-shown-in-response-is-ordered-in-a-desc/9806>\
**Category:** Help Hub\
**Created:** [December 27, 2019, 7:33pm UTC](https://community.postman.com/t/how-can-i-validate-that-a-date-shown-in-response-is-ordered-in-a-desc/9806 "2019-12-27T19:33:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guillermo.munozvilla](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@guillermo.munozvilla](https://community.postman.com/u/guillermo.munozvilla)\
**Post date:** [December 27, 2019, 7:33pm UTC](https://community.postman.com/t/how-can-i-validate-that-a-date-shown-in-response-is-ordered-in-a-desc/9806/1 "2019-12-27T19:33:32Z")

</div>

This is my response json  
{  
“ContactMethods”: [  
{  
“idClientContactMethod”: 1507408,  
“contactMethod”: {  
“description”: “TELEFONO TRABAJO”,  
“idContactMethod”: 3  
},  
“value”: “”,  
“acceptOffers”: false,  
“isMain”: true,  
“createdDate”: “02/12/2019 21:32:52”,  
“createdUser”: “yyyy”,  
“modifiedDate”: “06/12/2019 14:14:52”,  
“modifiedUser”: “1911201”  
},  
{  
“idClientContactMethod”: 1507388,  
“contactMethod”: {  
“description”: “TELEFONO”,  
“idContactMethod”: 2  
},  
“value”: “987654321”,  
“acceptOffers”: true,  
“isMain”: true,  
“createdDate”: “02/12/2019 17:33:30”,  
“createdUser”: “1911201”,  
“modifiedDate”: “02/12/2019 17:33:30”,  
“modifiedUser”: “1911201”  
},  
{  
“idClientContactMethod”: 1507386,  
“contactMethod”: {  
“description”: “CELULAR”,  
“idContactMethod”: 1  
},  
“value”: “valffor”,  
“acceptOffers”: false,  
“isMain”: true,  
“createdDate”: “02/12/2019 17:04:13”,  
“createdUser”: “1911201”,  
“modifiedDate”: “02/12/2019 17:04:13”,  
“modifiedUser”: “1911201”  
},  
{  
“idClientContactMethod”: 3533,  
“contactMethod”: {  
“description”: “TELEFONO”,  
“idContactMethod”: 2  
},  
“value”: “8183548”,  
“acceptOffers”: false,  
“isMain”: false,  
“createdDate”: “17/11/2019 00:00:00”,  
“createdUser”: “Carga Inicial”,  
“modifiedDate”: “22/11/2019 18:22:56”,  
“modifiedUser”: “CARGA INICIAL”  
}  
]  
}

and the validation I was doing in this way but it generates an error

var \_ = require(‘lodash’),

```
// Parse the array returned in the response body (It is probably a stringified response)

responseArray = JSON.parse(responseBody);
console.log(responseArray);

```

pm.test(‘Validate Date ContactMethods’, () =\> {  
// Use the responseArray here  
var expectedSortedOrder = \_.orderBy(responseArray.ContactMethods, [‘modifiedDate’],[‘DESC’]);

```
pm.expect(responseArray.ContactMethods).to.eql(expectedSortedOrder);

```

});

 ![imagen](https://us1.discourse-cdn.com/getpostman/original/3X/1/3/13caaa38237185372b7b418dc637bc689cb8f914.png)

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [December 28, 2019, 2:29pm UTC](https://community.postman.com/t/how-can-i-validate-that-a-date-shown-in-response-is-ordered-in-a-desc/9806/2 "2019-12-28T14:29:13Z")

</div>

You need to split this in smaller problem.

I think you first should find a way to parse your date in something that JavaScript can understand.

Use currently have the format dd/mm/yyyy but JavaScript works with mm/dd/yyyy.
