Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query influxdb for a date

Tags:

influxdb

I have a table in influxdb that has a column called 'expirydate'. In the column I have afew dates e.g. "2016-07-14" or "2016-08-20". I want to select only the 2016-07-14 date, but I am unsure how? My query is currently:

SELECT * FROM tablee where expirydate = '2016-07-14' limit 1000

But this does not work. Can someone please help me?

like image 670
Jonathon Hill Avatar asked Dec 11 '22 16:12

Jonathon Hill


2 Answers

Assuming the value table**e** is a valid measurement...

If you are looking at selecting all of the points for the day '2016-07-14', then your query should look something like.

Query:

SELECT * FROM tablee where time >= '2016-07-14 00:00:00' and time < '2016-07-15 00:00:00'

You might also be interested in the influx's date time string in query.

See: https://docs.influxdata.com/influxdb/v0.9/query_language/data_exploration/#relative-time

Date time strings
Specify time with date time strings. Date time strings can take two formats: YYYY-MM-DD HH:MM:SS.nnnnnnnnn and YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ, where the second specification is RFC3339. Nanoseconds (nnnnnnnnn) are optional in both formats.

Note: The limit api could be redundant in your original query as it is there to impose restriction to the query from returning more than 1,000 point data.

like image 89
Samuel Toh Avatar answered Dec 22 '22 22:12

Samuel Toh


I had to force influx to treat my 'string date' as a string. This works:

SELECT * FROM tablee where expirydate=~ /2016-07-14/ limit 1000;
like image 35
Jonathon Hill Avatar answered Dec 22 '22 20:12

Jonathon Hill