Jonathon Hill
Jonathon Hill

Reputation: 1057

Query influxdb for a date

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?

Upvotes: 6

Views: 38437

Answers (2)

Samuel Toh
Samuel Toh

Reputation: 19228

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.

Upvotes: 14

Jonathon Hill
Jonathon Hill

Reputation: 1057

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;

Upvotes: 1

Related Questions