Help - MQTT JSON reformat date field prior to insert into mySQL

I have an MQTT subscription which outputs parsed JSON into a function that reformats and outputs a message:

  • MQTT > Function 'Reformat Message' > Function 'Create SQL' > mySQL connection

The challenge I'm facing is reformatting the JSON date into a mySQL datetime value, I've found the moments formats which is correctly formatting the date but I'm struggling on how to either update the date value or join the data:

  • MQTT > Function Moments > Function 'Reformat Message' > Function 'Create SQL' > mySQL connection *** The moments function only outputs the date and not the original MQTT data

  • MQTT > Function 'Reformat Message' > JOIN >Function 'Create SQL' > mySQL connection
    > Function Moments --------------> *** The join is not inserting correctly formatted data

The only way I have managed to get this to work is as follows:

  • MQTT > Function 'Reformat Message' > JOIN >Function 'Create SQL' > mySQL connection
    > Function Moments > GLOBAL value *** The Create SQL function then uses the GLOBAL value

Is there a better way to achieve what I need to do, reformat date, my concern with my working solution relates to when the GLOBAL value is set, will this be set before the Create SQL is run?

you could probably reformat the data with a JSONata expression in a change node, or JS in a function node, i doubt you would need a join. It would help if you supplied an example (text not an image) of the incoming data, and how you wanted it formatted.

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