I'm relatively new to node-red. I've searched and cannot seem to find a "simple" solution to what I want to do. It seems like I should be able to use a jsonata expression to create a filename in my write file node. I want the filename to be of the format:
/user/public/documents/battery/[msg.topic]_[YYYY-MM-DD].txt
where msg.topic is the message topic and YYYY-MM-DD is the current year, month and day.
I cannot seem to figure out to correct syntax to do this. I know I can do it with code in a function node and assign it to msg.filename, but I'd like to understand how to do it with jsonata. I "asked" ChatGPT how to do it and it came up with the following line, which does not work (for a number of reasons)
E1cid:
Thanks for your very rapid response. I have node-red-contrib-moment installed, but your solution fails with the error on moment "attempted to invoke a non-function". Do I need to do something else to get moment() to work?
I copied your text but failed to notice there was no $ before moment
edit post above.
p.s. I would add hours mins and seconds, other wise you could end up with all files on same day overwriting each other, unless that is what you want.