Diego
Diego

Reputation: 503

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.

Upvotes: 0

Views: 5000

Answers (2)

Diego
Diego

Reputation: 503

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.

Upvotes: 0

beckettsean
beckettsean

Reputation: 1846

You are specifying seconds as the precision in the query but supplying millisecond timestamps. 1432080000000s means 1432080000000 in seconds, which is October 22nd of the year 47350.

$ date -r 1432080000000 Thu Oct 22 16:00:00 PST 47350

In addition, you cannot perform a GROUP BY without an aggregation function in the SELECT statement. It makes no sense to ask for a daily summary of all points and then give no way for the results to be aggregated into daily values. Remove the GROUP BY clause to return all points in the time range. (Also your GROUP BY syntax is incorrect. The proper syntax would be GROUP BY time(1d).)

Your query should be: select * from items where id = '11111111111' and time > 1432080000s and time < 1432177199s

Upvotes: 1

Related Questions