6

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?

Jonathon Hill
  • 1,007
  • 4
  • 16
  • 23

2 Answers2

14

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.

Samuel Toh
  • 18,006
  • 3
  • 24
  • 39
1

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;
Jonathon Hill
  • 1,007
  • 4
  • 16
  • 23
  • So the query suggested by me didn't work for you? Also, have you tried enquoting the string? Doing `=~ /.../~ means are running a regular expression. Just out of curiousity is `expirydate` actually a tag, I suppose you are not actually looking for a query by would filter by real date... Assuming `expirydate` is a tag then a string match would have done the job. – Samuel Toh Jul 11 '16 at 06:58