# Influxdb in node time precision

**URL:** <https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640>\
**Category:** General\
**Created:** [3 July 2022 17:14 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640 "2022-07-03T17:14:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)\
**Post date:** [3 July 2022 17:14 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/1 "2022-07-03T17:14:35Z")

</div>

Version [V1.x]. At "influxdb in" node, the default time precision is "ms".  
In the advanced query option of the "influxdb in" node, changed the time precision to "Microsecond (u)", but the query result is still showing "Millisecond (ms)" resolution in the debug window of node-RED. Also when using function node to handle the output from the node, the precision is also "ms".

"Raw output" from the "influxdb in" node gives higher timing resolution.  
Is this a bug from the node?

![microsecond](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/30cba7a10f78120c01bb1587d1279a2d4178690b.jpeg)

 ![resolution](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/c/bc9fa45c67501ec53dcda3294979c6a9389e9b55.jpeg)

---

<div class="post-metadata">

**Author:** ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)\
**Post date:** [3 July 2022 17:42 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/2 "2022-07-03T17:42:55Z")

</div>

Here is the screen shot of the raw output from the "influxdb in" node.  
The debug window can display higher time precision. So it should be the "influxdb in" node issue. Its time precision does not work.

 ![raw output](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c331bd495de86216f5c347fe4228dd5c6bf509a7.jpeg)

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [4 July 2022 07:01 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/3 "2022-07-04T07:01:53Z")

</div>

What value is given if you click in the debug window on the date/time string?  
When clicking on it it will give you the timestamp.

---

<div class="post-metadata">

**Author:** ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)\
**Post date:** [4 July 2022 14:39 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/4 "2022-07-04T14:39:02Z")

</div>

Solved the problem with the following approach:

1. Read out the first data in millisecond resolution, then calculating the time passed for the remaining samples using microseconds based on the sampling rate. Use this new time stamps with microseconds resolution.
2. Convert the time stamp (number) to strings, and use strings instead of time stamps for the Plotly chart x-axis time input (The Plotly charts only have millisecond resolution too 🤣).
3. Format the chart x-axis ticks to display like date/time nicely

@edje11 The Influxdb in node read out is a string (We saved the timestamp with mciro seconds resolution with "microtime" function at influxdb out node.) Querying the database in command line shows correct time stamps.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 July 2022 06:56 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/5 "2022-07-05T06:56:38Z")

</div>

I know you have solved your problem, but I've been working with the [influx](https://www.npmjs.com/package/influx) package (which is used by the Influx Nodes) on a current project.

For the `time` field it returns objects of a custom Date class (`NanoDate`) with additional methods providing access to the higher resolution timestamps returned by Influx.

So I think the output you see in the debug panel is just a `toString()` representation of that NanoDate object in standard ISO 8601 notation (milliseconds).

Here's an excerpt of the output I get via `console.dir()` for the time field:

```auto
time: 2022-06-27T11:30:42.546Z {
      _nanoISO: '2022-06-27T11:30:42.546Z',
      getNanoTime: [Function: getNanoTimeFromISO],
      toNanoISOString: [Function: toNanoISOStringFromISO]
},

```

I hope that info is helpful, maybe you can simplify some things. 🙂

---

<div class="post-metadata">

**Author:** ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)\
**Post date:** [5 July 2022 16:30 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/6 "2022-07-05T16:30:32Z")

</div>

Thanks much Kuema.

This is good to know. I will look into this when time allows. Yes this indeed could simply things.

---

<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:** [19 July 2022 16:30 UTC](https://discourse.nodered.org/t/influxdb-in-node-time-precision/64640/7 "2022-07-19T16:30:56Z")

</div>

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