Read-Commands InfluxDB

Hello Node-Red Community

I wanna read the influx database. I found the following command for this. "SELECT "value" FROM Zimmer_Temp WHERE time >= '2022-06-03' LIMIT 1"

I can run this from the command line. It also works if I type this directly in the "influxdb in" node in NodeRed. (See photo)

However, there is a syntax error with the "function" node. (See photo)

I want to define the date via a variable, there for the function. Is there a way to change the syntax in the "function" node to "Query"?

Thanks for your support!

msg.query = "SELECT value FROM Zimmer_Temp WHERE time >= '" +  msg.payload.time + "' LIMIT 1";

Or

msg.query = `SELECT "value" FROM Zimmer_Temp WHERE time >= '${msg.payload.time}' LIMIT 1`;

notice the type of quotes on second example Template literals (Template strings) - JavaScript | MDN . You do not need quote around the table column names.

Hello @E1cid

Thanks for your support.

This helps me a lot. Now i got another problem.

See down the print screen. I would like to be able to realize the complete query with variables. The one marked in green already works, but i got some problems with de yellow ones, because they absolutely have to stand between two quotation marks.

If i do it like this, it doesn't works...

Would you have another tip for me?

Tanks!

try adding quotes around the 01_00, as the db is seeing it as a number i suspect.

p.s. when posting code it is best to copy and paste text between triple backticks, use the </> button