I have a SharePoint list. It has two columns Start date and End date. I need to query and get data if (start date + 7 days> End date). Through CAML builder its not possible to have a SharePoint column on value node and build the query. Any idea? I have tried below. But not working.
<Query>
<Where>
<Eq>
<FieldRef Name='EndDate' />
<Value IncludeTimeValue='TRUE' Type='DateTime'><StartDate+7/></Value>
</Eq>
</Where>
</Query>
You can not compare two field of item to each other in CAML query. You can either create computed field and do the compare in it or you can use LINQ. Something like this:
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;