# Read-Commands InfluxDB

**URL:** <https://discourse.nodered.org/t/read-commands-influxdb/63518>\
**Category:** General\
**Created:** [6 June 2022 14:55 UTC](https://discourse.nodered.org/t/read-commands-influxdb/63518 "2022-06-06T14:55:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyrillschuerch](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cyrillschuerch](https://discourse.nodered.org/u/cyrillschuerch)\
**Post date:** [6 June 2022 14:55 UTC](https://discourse.nodered.org/t/read-commands-influxdb/63518/1 "2022-06-06T14:55:16Z")

</div>

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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d2f2e0e8772a88bc0f3db27808bc6499115285c.png)

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

 ![Unbenannt](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa33eaf1d349c1d7410a8a4068833c1546a6df2a.png)

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!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [6 June 2022 15:06 UTC](https://discourse.nodered.org/t/read-commands-influxdb/63518/2 "2022-06-06T15:06:55Z")

</div>

> [@cyrillschuerch](#):
>
> "SELECT "value" FROM Zimmer\_Temp WHERE time \>= '2022-06-03' LIMIT 1"

```auto
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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) . You do not need quote around the table column names.

---

<div class="post-metadata">

**Author:** ![cyrillschuerch](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cyrillschuerch](https://discourse.nodered.org/u/cyrillschuerch)\
**Post date:** [3 July 2022 11:24 UTC](https://discourse.nodered.org/t/read-commands-influxdb/63518/3 "2022-07-03T11:24:44Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f598d71837be38b81ae78d45ba5f4b39a8e7348.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e614a086bebbd98fcea07d190ba26833efaca77.png)

Would you have another tip for me?

Tanks!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [3 July 2022 11:41 UTC](https://discourse.nodered.org/t/read-commands-influxdb/63518/4 "2022-07-03T11:41:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 September 2022 11:42 UTC](https://discourse.nodered.org/t/read-commands-influxdb/63518/5 "2022-09-01T11:42:07Z")

</div>

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