Help| how to add timestamp into csv file

Hello all, recently i have manage to split data from MQTT and saved as CSV ,thanks to forum member that really kind and helpfull.

For now i want to do is add timestamp(if im not mistaken) which add date and time of data taken.the date and time is already stated in the MQTT and Node-red , how to refer it and add it into csv file..

i have read some example and tried but fail, the result as below:

the yellow highlight is the data and time im trying to add into csv and the properties is the code.. in the csv it appear the random number not value of axis

what i expected it to be as below

the current view of node-red flow

You should be able to add to the string in the change nodes.
Try using $moment(), you can set the time zone if you wish to.
JSONata expression

"X-AXIS," & $$.payload.`X-AXIS` & $moment().tz("Asia/Tokyo").format(",DD/MM/YYYY,h:mm:ss a")

https://momentjs.com/timezone/

thanks , i will try it and post the result here

since i have 3 change node for 3 axis
for y-axis
"Y-AXIS," & $$.payload.Y-AXIS & $moment().tz("Asia/Tokyo").format(",DD/MM/YYYY,h:mm:ss a")
for z-axis
"Z-AXIS," & $$.payload.Z-AXIS & $moment().tz("Asia/Tokyo").format(",DD/MM/YYYY,h:mm:ss a")

the result,(probably due to function split,,as im changing to JSON string will fix it and repost)

You have changed the payload coming in from the mqtt node.
you no longer need the function node. I did mention this in the other thread.

yes, i did remove the function node but error occoured, i did send picture of the result to the other thread

Pictures are no good we need to see the expression you edited, we can not mind read the info.

1 Like

ok noted, i will share the info

@dceejay @Colin can you merge the threads as they are about the same thing.

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