Search code examples
javascriptnode.jsinfluxdb

Search times with Timestamp in milliseconds influxdb


In influx i'm replacing the time for a time given by a gps module. It's save the date in Unix epoch time like this 1432600783000.

When I try to execute a query like this in influxdb:

select * from items where id = '11111111111' and time > 1432080000000s and time < 1432177199000s group by (1d)

Date 1432080000000: GMT: Wed, 20 May 2015 00:00:00 GMT Your time zone: 19/5/2015 21:00:00 GMT-3:00

Date 1432177199000: GMT: Thu, 21 May 2015 02:59:59 GMT Your time zone: 20/5/2015 23:59:59 GMT-3:00

It don't returns anything, what is the correct way to filter a date, for example bring the points between two dates.

Thanks.


Solution

  • I have to change before to send the data to the query to UTC time like this:

    select * from items where id = '11111111111' and time > '2015-05-20 03:00:00' and time < '2015-05-20 03:00:00' + 1d  group by time(1d)
    

    To do this I used moment js like this:

    moment.utc(date).format('YYYY-MM-DD hh:mm:ss')
    

    Then the date is send in the format 2015-05-20 03:00:00 that reflex the timezone where I am.