# Check format date with Postman

**URL:** <https://community.postman.com/t/check-format-date-with-postman/28359>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [October 2, 2021, 4:08pm UTC](https://community.postman.com/t/check-format-date-with-postman/28359 "2021-10-02T16:08:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mld1954](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mld1954](https://community.postman.com/u/mld1954)\
**Post date:** [October 2, 2021, 4:08pm UTC](https://community.postman.com/t/check-format-date-with-postman/28359/1 "2021-10-02T16:08:08Z")

</div>

Hello 🙂

I want to create a test that validates if the date format respects this: YYYY-MM-DD

in the body I have this answer:

“date”: “2021-10-29”

help me please

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [October 3, 2021, 12:02am UTC](https://community.postman.com/t/check-format-date-with-postman/28359/2 "2021-10-03T00:02:43Z")

</div>

@mld1954 Welcome to the community 🥳

Please refer the similar post discussed [here](https://community.postman.com/t/verify-a-date-format-from-a-post-response/11046/4).

Something like below would work too:

```auto
var jsonData = pm.response.json();
console.log(jsonData.data)

let date = jsonData.data;

let moment = require ('moment');

pm.test("Checking data format", function () {
    pm.expect(date).to.include(moment(date).format('YYYY-MM-DD'));
});

```

---

<div class="post-metadata">

**Author:** ![mld1954](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mld1954](https://community.postman.com/u/mld1954)\
**Post date:** [October 3, 2021, 1:09am UTC](https://community.postman.com/t/check-format-date-with-postman/28359/3 "2021-10-03T01:09:32Z")

</div>

Thank you very much @bpricilla🙂
