Portfedh
Portfedh

Reputation: 328

How to export influxdb database to csv with RFC3339 timestamps

I would like to export my InfluxDB database to a CSV file. Im currently using the following code:

$ influx -database 'Dabtabase_name' -execute 'SELECT * FROM table_name' -format csv > test.csv

The code works but timestamps are displayed as numbers as follows:

1609459200000000000

I would like to save it in a way where the timestamp is saved in RFC3339 format, like this:

2021-01-01T00:00:00

Upvotes: 1

Views: 3973

Answers (1)

arun n a
arun n a

Reputation: 906

When you first connect to the CLI, specify the rfc3339 precision

$ influx -precision rfc3339

To get RFC 3339 when you export to CSV use this.

$ influx -precision 'rfc3339' -database 'Dabtabase_name' -execute 'SELECT * FROM table_name' -format csv > test.csv

Upvotes: 2

Related Questions