Pick a especific part of a String in response body

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.

Hey @hrosani84 :wave: Welcome to the community :confetti_ball:

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.

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 :+1:

1 Like

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