How to export influxdb database to csv with RFC3339 timestamps

3.5k Views Asked by At

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
1

There are 1 best solutions below

0
arun n a On BEST ANSWER

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