2

日期比较在 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>",
4

2 回答 2

2

试试这个

<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>

于 2013-12-11T07:29:41.493 回答
0

仅供参考,我做了一个 JavaScript API 库来处理 Sharepoint:http ://aymkdn.github.io/SharepointPlus/

好处之一是您不再需要担心 CAML 查询。例如,在您的情况下,您可以这样做:

// 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"))
})

注意:可以查看浏览器控制台查看是否有错误

于 2013-12-12T08:51:41.653 回答