# Influxdb data into a csv file

**URL:** <https://community.influxdata.com/t/influxdb-data-into-a-csv-file/17978>\
**Category:** Systems\
**Created:** [January 22, 2021, 12:40pm UTC](https://community.influxdata.com/t/influxdb-data-into-a-csv-file/17978 "2021-01-22T12:40:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asif](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@asif](https://community.influxdata.com/u/asif)\
**Post date:** [January 22, 2021, 12:40pm UTC](https://community.influxdata.com/t/influxdb-data-into-a-csv-file/17978/1 "2021-01-22T12:40:53Z")

</div>

I have downloaded the database data into csv file by using following command

**influx -database ‘database\_name’ -execute ‘SELECT \* FROM table\_name’ -format csv \> test.csv**

It worked fine for me, but unfortunately timestamp has not the proper format to be read the corect time and date.

 ![Screenshot (200)](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/3/38af700f13aafc9bfcf6fffd8ed7d2ea67d0ccd9.png)

How can i get the proper time stamp?

Thank you

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [January 22, 2021, 8:12pm UTC](https://community.influxdata.com/t/influxdb-data-into-a-csv-file/17978/2 "2021-01-22T20:12:01Z")

</div>

Hello @asif ,  
Hello you can use any language you want to convert from unix timestamp to ISO 8601.  
Here’s a python example:

```auto
import pytz
from datetime import datetime

tz = pytz.timezone('America/Los_Angeles')
print(datetime.fromtimestamp(1463288494, tz).isoformat())

```

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [January 22, 2021, 8:13pm UTC](https://community.influxdata.com/t/influxdb-data-into-a-csv-file/17978/3 "2021-01-22T20:13:50Z")

</div>

Hello @asif ,  
Here’s a stack overflow for google sheets too

> <https://stackoverflow.com/questions/45227380/convert-unix-epoch-time-to-date-in-google-sheets>

---

<div class="post-metadata">

**Author:** ![samdanisms](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@samdanisms](https://community.influxdata.com/u/samdanisms)\
**Post date:** [April 11, 2021, 7:49am UTC](https://community.influxdata.com/t/influxdb-data-into-a-csv-file/17978/4 "2021-04-11T07:49:00Z")

</div>

How did you make it work @asif I tried a couple of times but to no avail. The following is the command I used:

influx -database ‘chirpstack’ -execute ‘SELECT \* FROM device\_frmpayload\_data\_BC’ -format csv \> test.csv

It throws the following error:  
ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

How do I fix the error? Also I’d like to know if there’s a way by which I can export the database in one go, instead of exporting one measurement/table one at a time? Many thanks in advance.
