I’m using a CAML query to get events between two specific dates from a calendar. However, when the query runs it is still returning all of the events with the list. It looks as if it is not applying the ‘and’ operator correctly.
My code is:
camlQuery.set_viewXml('<View><GetListItems><Where><And>' +
'<Gt><FieldRef Name="EventDate" /><Value IncludeTimeValue="TRUE" Type="DateTime">' +
startDate + '</Value></Gt>' +
'<Lt><FieldRef Name="EventDate" /><Value IncludeTimeValue="TRUE" Type="DateTime">' +
endDate + '</Value></Lt></And></Where>' + '
<ViewFields><FieldRef Name="Title" /><FieldRef Name="EventDate" /></ViewFields>' +
'<QueryOptions /></GetListItems></View>');
startDate and endDate are converted to ISO8601 format, if I just do the greater part of the caml query then I return all list items after that date. It’s just when adding in the less than part of the caml query I start getting errors. The caml works fine in U2U query builder.
Any help would be much appreciated.
I’ve changed the query evaluators from to and to and also removed the tags and this seems to have done the trick