简体   繁体   中英

Date comparison is not working in sharepoint spservices

Date Comparission在sharepoint sp服务中不起作用...我想获取等于当前年份的记录(即2013)

   CAMLQuery: "<Query><Where><Geq><FieldRef Name='EventDate' /></Value><Value Type='DateTime' IncludeTimeValue='TRUE'>2013-12-10T12:00:00Z</Value></Geq></Where><OrderBy><FieldRef Name='EventDate' /></OrderBy></Query>",

尝试这个

<Query><Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime' IncludeTimeValue='TRUE'>2013-12-10T12:00:00Z</Value></Geq></Where><OrderBy><FieldRef Name='EventDate' /></OrderBy></Query>

FYI I did a JavaScript API library for dealing with Sharepoint: http://aymkdn.github.io/SharepointPlus/

One of the good thing is that you don't need to worry anymore about the CAML Query. For example in your case you could do :

// define your date in JavaScript
// and use $SP().toSPDate() to convert it to the right format
var eventDate = $SP().toSPDate(new Date("2013/12/10"));

// call $SP().list().get() to get your data with the "where" parameter
$SP().list("Name of your list").get({
  fields:"EventDate",
  where:"EventDate >= '"+eventDate+"'",
  orderby:"EventDate DESC"
}, function(data) {
   for (var i=data.length; i--;) console.log(data[i].getAttribute("EventDate"))
})

Note: you can check the browser console to check if there is any error

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