简体   繁体   中英

javascript caml query returning all date values

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.

我将查询评估程序从和更改为,还删除了标签,这似乎可以解决问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM