Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2010 使用SharePoint列SharePoint 2010创建具有值字段的CAML查询_Sharepoint 2010_Caml - Fatal编程技术网

Sharepoint 2010 使用SharePoint列SharePoint 2010创建具有值字段的CAML查询

Sharepoint 2010 使用SharePoint列SharePoint 2010创建具有值字段的CAML查询,sharepoint-2010,caml,Sharepoint 2010,Caml,我有一个SharePoint列表。它有两列开始日期和结束日期。 我需要查询和获取数据,如果(开始日期+7天>结束日期)。 通过CAML builder,无法在值节点上拥有SharePoint列并生成查询。 有什么想法吗? 我在下面试过了。但不起作用 <Query> <Where> <Eq> <FieldRef Name='EndDate' /> <Value IncludeTimeValu

我有一个SharePoint列表。它有两列开始日期和结束日期。 我需要查询和获取数据,如果(开始日期+7天>结束日期)。 通过CAML builder,无法在值节点上拥有SharePoint列并生成查询。 有什么想法吗? 我在下面试过了。但不起作用

<Query>
   <Where>
      <Eq>
         <FieldRef Name='EndDate' />
         <Value IncludeTimeValue='TRUE' Type='DateTime'><StartDate+7/></Value>
      </Eq>
   </Where>
</Query>

应使用GeQ、LeQ代替EQ


我还没有试过,我自己。

在CAML查询中,您不能将两个项目字段相互比较。您可以创建计算字段并在其中进行比较,也可以使用LINQ。大概是这样的:

SPList tasks = SPContext.Current.Web.Lists["tasks"];
var ts = from t in tasks.Items.OfType<SPListItem>() where t["DueDate"] == null || (DateTime)t["Modified"] > (DateTime)t["DueDate"] select t;
SPList tasks=SPContext.Current.Web.Lists[“tasks”];
var ts=来自tasks.Items.OfType()中的t,其中t[“DueDate”]==null | | |(DateTime)t[“Modified”]>(DateTime)t[“DueDate”]选择t;

我建议创建一个计算列来计算开始日期和结束日期之间的差异:

=日期dif([已创建],[结束日期],“d”)

然后在camlquery过滤器中使用大于或等于7天的时间

<Query>
   <Where>
      <Geq>
         <FieldRef Name="DateDiff"/>
         <Value IncludeTimeValue='TRUE' Type='Number'>7<Value>
      </Geq>
   </Where>
</Query>

7.