0

var result = 'select message from people.users where event_time > ? and event_time < ? allow filtering';

client.execute(result,[startdate,enddate], function(err,result)

This is not working its showing :

GET /favicon.ico 500 17.785 ms - 386
{ [ResponseError: Expected 8 or 0 byte long for date (10)]
  name: 'ResponseError',
  message: 'Expected 8 or 0 byte long for date (10)',
  info: 'Represents an error message from the server',
  code: 8704,
  query: 'select message from people.users where event_time > ? and event_time <
 ? allow filtering' }
Ben Fortune
  • 31,623
  • 10
  • 79
  • 80
Syed Ammar Mustafa
  • 373
  • 1
  • 7
  • 18

1 Answers1

0

There is a mismatch between the type expected by Cassandra (timestamp) and the value provided (it looks like it is not Ecmascript Date).

It should be something like:

var startDate = new Date('2015-01-01');
var endDate = new Date();
var query = 'select message from people.users where event_time > ?' +
            ' and event_time < ? allow filtering';
client.execute(query, [startDate, endDate], { prepare: true}, callback);

Also, you should use the prepare flag for best performance and for accurate type mapping between Ecmascript and Cassandra.

jorgebg
  • 6,560
  • 1
  • 22
  • 31