Timestamp convert format of a csv file


#1

i have this code , to download datas from a valve in command window
Example:
influx -database fielddata -host xyxy.com -port xyxy -execute “select * from zones WHERE (valve = ‘101’) AND time > ‘2018-03-23’ and time < ‘2018-04-23T23:59:59Z’” -format csv > test.csv

the problem is that get timestamps like that: time:1521763242000000000
i have no clue how i can convert it…i need help:-(
i would like to have this format: 2015-07-17T20:32:58
i have read something about " precision rfc3339" but i have no clue where i have to put in the code above.
Thank you for your help.


#2

In the code above, you should be able to add -precision rfc3339 to get the format you want.


#3

Hey Katy thank you, it works!
Hey influx --precision rfc3339 -database fielddata -host xyxy.com -port xyxy -execute “select * from zones WHERE (valve = ‘101’) AND time > ‘2018-03-23’ and time < ‘2018-04-23T23:59:59Z’” -format csv > test.csv
i have another question:
what kind of meaning has the letter Z for the time (2018-04-23T23:59:59Z)?


#4

You’re using RFC 3339 format. RFCs document various technologies used to make the internet work, and can be found through a quick Google search.

In this case, here is the relevant definition from the RFC:

      Z           A suffix which, when applied to a time, denotes a UTC
                  offset of 00:00; often spoken "Zulu" from the ICAO
                  phonetic alphabet representation of the letter "Z".

#5

@ilmiomondo The Z is just part of the formatting. It’s common when timestamps get returned in JSON, as well as some other formats.