Flux: Get value by _time

Hi all,

I want to get data with specific date (saved as timestamp). I’ve tried filtering by _time, but I don’t see any results.
Used query is:

from(bucket: “sample_bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “versions” and r.project == “sample_project” and r._field == “commit” and r._time == time(v: 1689681583))

Is it possible to get value “commit” having specified timestamp? What is wrong in this query?

Thanks a lot :slight_smile:

are you sure that the timestamp is correct?

I have done that, and you can definitely filter by time.

Make sure that your _time value is between the range you selected first, you could use:

|> range(start:0)

to make sure you have all _time values but I only recommend that If you are going to use filter by _time or if you don’t have too many data points.

Thank you @fercasjr :slight_smile:

I checked correctness of the timestamp and it is correct.
Is timezone (or another thing) important to query by _time?

yes, everything in InfluxDB is stored as UTC timestamp. you could set time zone

or time offset to accommodate to local time.

timezone.fixed() function | Flux 0.x Documentation (influxdata.com)

I know what the problem is!!!
time(v: 1689681583) = 1970-01-01 00:00:01 UTC

remember that Influx time is in ns:

I found this information too and it was a reason of issue.

@fercasjr thanks :slight_smile: