Hi There,
I have an object in my message payload (payload.Time) that I would like to split into two separate objects. I think the answer must be really simple with a function node I guess but I am just hitting a stumbling block.
The string appears to be a fixed length.
Hopefully the picture explains my aim.
Change the single string in payload.Time to 2 strings 1) payload.Date & 2)payload.Time
Thanks Iain
There are multiple ways, example in function node
const input = msg.payload.Time.split("T")
const date = input[0]
const time = input[1]
msg.payload = {date,time}
return msg
or use
msg.payload = {date_time:{date,time}}
if you want to have them sitting inside another property.
Small tip, don't use 'exotic' characters in property names, it will come to bite you later.
I think the op wants to keep the other data.
const input = msg.payload.Time.split("T")
const date = input[0]
const time = input[1]
msg.payload.dateTime = {date, time}
return msg
Much appreciated bakman2. Second use case was exactly what I was after
Yes I did, I'm somewhat hesitant to ask for everything to be done for me though 