var queryApi = client.GetQueryApi();
var tables = queryApi.QueryAsync(query).Result;
In fact any query I run truncates the timestamp in the same way.
What can I do to retrieve the timestamp in the millisecond precision in which it exists in the database, and why is it being truncated in the first place?
BTW, this is the query in the Data Explorer that was used to get the data to see what the timestamp looked like. I’m only able to use SQL and not Flux.
SELECT *
FROM “wave_intensity”
WHERE
time >= now() - interval ‘1 day’
@JasonJ55 AFAIK, the query API doesn’t truncate any timestamps. All timestamps are returned in nanosecond precision. Any truncation that happens is done client-side and is likely only done for display purposes.
Thanks @scott
In that case, what’s the standard way to get the actual timestamp and not a truncated display version. However I try and finesse “_time” in the FluxRecord, it’s only to the second. I can’t find any examples online of retrieving the timestamp.
AFAIK, clients shouldn’t manipulate any of the timestamps returned in a query. With the SQL query, are you using the C# client or are you using the Data Explorer to execute the query?
I’m using the C# client and a flux query. For the SQL query I use Data Explorer, and that gives the timestamp fully accurate timestamp. The reason I wanted the timestamp through the C# client, and accurate to at least the millisecond, is that I need to know the time when each datapoint was generated and we have many per second during an operation. I’ve solved this by adding a “ticks” field to the written data and use that to hold the time of each datapoint (or more specifically, for each point, the number of ticks elapsed since the start of the operation). Hence, I no longer need the timestamp but was nonetheless curious on how to retrieve it, given that it is, after all, time-series data.
Unfortunately I still haven’t found an answer to this problem.
A Flux query always has the timestamp to the second e.g.
2024-08-05T20:34:18Z
But I need it to be at least to the millisecond e.g.
2024-08-05T20:34:18.827Z
Days of online searching have not turned up anything useful.
Do I set something when I initialize the API client? (although I read that the default precision to nanosecond).
Should I abandon using Flux if this issue is baked in?
The InfluxDB timestamp is a NodaTime.Instant. This object has no public members, so the exact time cannot be obtained; but it can be converted into a DateTime, through which the full time can be accessed.