SUBSTR in Change Node - HELP Needed

Hi all

I have a Date and Time string - a runrise date and time - which I am simply looking to extract the time. from. But I keep getting an "undefined" result in the debug messages

Here is a string sample - "2022-11-23T08:04:01+0000"

I have a change node to give me msg.payload from msg.payload.sunriseTimeLocal.substr(11,5), so it doesn't like the substr(11,5)

Where am I going wrong please ?

Change nodes are static unless you use JSONata, you can't use JavaScript.

Ah ha,

As it turns out, it IS part of JSON Data. The actual element (if that is the correct word !!) is

It contains "2022-11-23T08:04:01+0000"

So how would I get 08:04 out of this

You can use the change node with a JSONata expression:


If you only want the first one in the array


Thanks for that. I must be missing a plugin or some node. I have the Moment plugin installed. I only need the first one in the array

You don't need the moment plugin, it is part of the jsonata package within node-red.

How did you configure the change node ? Did you set it to an jsonata expression ?

Ah - I missed the jsonata expression bit

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.