Search code examples
influxdb

Write data to influxDB for old date


I am trying to write data into influx db using HTTP API.

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary "poc_test,First_Name=Ajay,Last_Name=Kumar Age=25"

it successfully writes data with current point (timestemp) in DB. However I want to write data of two years back and want timestamp should also be of two years back. if there anyway I can do this, I know i can write it by putting time-stamp to the end of query but I do not know how to convert that date to time-stamp.

e.g.- i have data like this

First_Name:- Ajay
Last_Name:- Kumar

above data belongs to 17/04/2016

When i insert this data to influxdb and I hot a query to

select * from poc_test
name: poc_test
time                           First_Name   Last_Name      Age
----                           ----------- ------------- ---------
**2016-04-17T00:00:00.020170822Z** Ajay        Kumar          25

Solution

  • The timestamp format is "nanoseconds since unix epoch". So convert your dates/times to nanoseconds, using the tools of your language/environment.

    For example, your timestamp "2016-04-17T00:00:00.020170822Z" would be "1460851200020170689" in nanoseconds.