1

I'm trying to run a command on influxDB using -execute from the cli

influx -execute 'select * from test_measurement where time > \‘2020-01-13T16:22:00Z\’ and time < \‘2020-01-13T16:22:30Z\’ -username uname -password pwd 

The query doesn't run as I'm unable to escape the single quotes(') for time condition. Can someone help with the syntax please.

Anil
  • 420
  • 2
  • 16

2 Answers2

0

Could you try:

influx -execute "select * from test_measurement where time > '2020-01-13T16:22:00Z' and time < '2020-01-13T16:22:30Z'" -username uname -password pwd 
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Nice. I know this wasn't in the original question, but how would this look if we wanted to include tags in it? For example select * from test_measurement where time > '2020-01-13T16:22:00Z' and time < '2020-01-13T16:22:30Z' and tagA = foo – ffi Aug 22 '22 at 19:32
0

time > 'date str'

would not work in influx cli because that is not a valid operator for string fields... I think you want a numeric value in the form of nanoseconds or whatever the precision of your db instance.

For string fields, one could use a regex match like

=~ /2020-01-*/

for all january 2020 matches, for instance.

bdekoz
  • 1