PolinaC
PolinaC

Reputation: 721

How to format time in influxdb select query

I am new to InfluxDB. I am querying data in admin ui. I see time as timestamp. Is it possible to see it formatted as date and time?

Upvotes: 72

Views: 149810

Answers (5)

Suyash
Suyash

Reputation: 335

Yes, you can craft your SQL "SELECT" query in the dashboard to display date and time by in this format "YYYY-MM-DD HH:mm:ss"

SELECT 
  dateTimeFormat(time, 'YYYY-MM-DD HH:mm:ss') AS formatted_time,
  *
FROM your_measurement
WHERE time >= $start_time AND time <= $end_time

Upvotes: 0

Tobias
Tobias

Reputation: 7415

Although thierry answered the question already, here is the link to the documentation as well:

precision 'rfc3339|h|m|s|ms|u|ns'

Specifies the format/precision of the timestamp: rfc3339 (YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ), h (hours), m (minutes), s (seconds), ms (milliseconds), u (microseconds), ns (nanoseconds). Precision defaults to nanoseconds.

https://docs.influxdata.com/influxdb/v1.5/tools/shell/#influx-arguments

Upvotes: 20

Demetris
Demetris

Reputation: 3241

The Web Admin Interface was deprecated as of InfluxDB 1.1 (disabled by default).

The precision of the timestamp can be controlled to return hours (h), minutes (m), seconds (s), milliseconds (ms), microseconds (u) or nanoseconds (ns). A special precision option is RFC3339 which returns the timestamp in RFC3339 format with nanosecond precision. The mechanism for specifying the desired time precision is different for the CLI and HTTP API.

To set the precision in CLI, you write precision <RFC3339|h|m|s|ms|us|ns> in the command line depending on what precision you want. The default value of the precision for the CLI is nanoseconds.

To set the precision in HTTP API, you pass epoch=<h|m|s|ms|us|ns> as a query parameter. The default value of the precision is RFC3339.

Upvotes: 9

Viraj Wadate
Viraj Wadate

Reputation: 6133

To convert influxdb timestamp to normal timestamp you can type on console:

influx -precision rfc3339

Now try with your query it should work.

For more details follow link : https://www.influxdata.com/blog/tldr-influxdb-tech-tips-august-4-2016/

Upvotes: 27

thierry
thierry

Reputation: 1411

You can select RFC 3339 formatting by entering the following command in the CLI:

precision rfc3339

Upvotes: 141

Related Questions