Sqlite INSERT command syntax

You have datetime in quotes so it has put that in as a string. You want something like

msg = "(UTC, DateTime, hp,lp) values (" + msg.payload + " , /"" +  datetime + "/", " + hp + ","+ lp + ")";

I think it is easier to get right using the syntax

msg = `(UTC, DateTime, hp,lp) values (${msg.payload} , "${datetime}", ${hp}, ${lp})`;

Don't use msg as a variable name unless it is a message, you will get confused at some point if you do that. At least I would.
Also it is good practice not to make a new message when returning, but return the original message after setting up the properties it needs.

1 Like