1

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
Portfedh
  • 178
  • 1
  • 13
  • 1
    When you first connect to the CLI, specify the rfc3339 precision: $ influx -precision rfc3339 influx -precision 'rfc3339' -database 'Dabtabase_name' -execute 'SELECT * FROM table_name' -format csv > test.csv If it works please let me know then I will add this comment to the answer. – arun n a Jun 15 '21 at 00:13
  • This worked. Thank you – Portfedh Jun 26 '21 at 01:12
  • Can i add it to the answer – arun n a Jun 28 '21 at 10:48
  • 1
    Of course. I did not understand why it was only a comment. I deleted the other one and upvoted the one you added. – Portfedh Jun 28 '21 at 18:40
  • Cruz Lemin Actually I posted the answer and someone has deleted it. I worked on InfluxDb 9 months before. – arun n a Jun 29 '21 at 03:19

1 Answers1

2

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
arun n a
  • 684
  • 9
  • 26