# Pick a especific part of a String in response body

**URL:** <https://community.postman.com/t/pick-a-especific-part-of-a-string-in-response-body/32738>\
**Category:** Help Hub\
**Tags:** variables, json\
**Created:** [February 18, 2022, 4:25pm UTC](https://community.postman.com/t/pick-a-especific-part-of-a-string-in-response-body/32738 "2022-02-18T16:25:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrosani84](https://avatars.discourse-cdn.com/v4/letter/h/e480ec/32.png) [@hrosani84](https://community.postman.com/u/hrosani84)\
**Post date:** [February 18, 2022, 4:25pm UTC](https://community.postman.com/t/pick-a-especific-part-of-a-string-in-response-body/32738/1 "2022-02-18T16:25:22Z")

</div>

Hi every one and I´m sorry about my english, it´s horrible, so, I need to take a date from response body, set in a variable but, separate months and years, below I print what I need, and tks for the community.

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/d/d3499d8fc0018ac8ce84dd6a79a232ee9e9e2a3f.png)

---

<div class="post-metadata">

**Author:** ![bbahadur](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@bbahadur](https://community.postman.com/u/bbahadur)\
**Post date:** [February 18, 2022, 5:05pm UTC](https://community.postman.com/t/pick-a-especific-part-of-a-string-in-response-body/32738/2 "2022-02-18T17:05:01Z")

</div>

Hey @hrosani84 👋 Welcome to the community 🎊

I’m not quite sure what type of response you are getting, but just to help you get the value of “validade” seperated as date, month and year, you could use the split function.

```auto
var response=pm.response.json()

var d_m_y=[] // to store the date, month and year seperately
d_m_y = response.validade.split('\\'+'/');

console.log(d_m_y)

```

Hope it helps,  
Good luck 👍

---

<div class="post-metadata">

**Author:** ![hrosani84](https://avatars.discourse-cdn.com/v4/letter/h/e480ec/32.png) [@hrosani84](https://community.postman.com/u/hrosani84)\
**Post date:** [February 19, 2022, 3:47pm UTC](https://community.postman.com/t/pick-a-especific-part-of-a-string-in-response-body/32738/3 "2022-02-19T15:47:47Z")

</div>

Thks bbahadur, it doesn’t work, bring me all date, what I need is something like this:

var date\_month = d\_m\_y[3…4]

var date\_year = d\_m\_y[6…7]

Set month and year in separate variables
