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('\\'+'/');


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