0

Is it possible to write a CAML query that uses another field as the Value part of the filter?

For example in SQL it would look like this:

WHERE Field1 > Field2

This was by best guess but it is not working:

<Gt><FieldRef Name='NoticeSentDate'/><Value Type='DateTime'><FieldRef Name='NoticeDate'/></Value></Gt>

1 Answer 1

1

Unfortunately, it cannot be done in CAML. If you have to use CAML, the recommended approach is created a calculated column such as =DATEDIF([NoticeSentDate], [NoticeDate],"d"). Your CAML query would then look for values greater than 0 in the calculated column.

Check out this page for more examples of date calculations in calculated columns:

http://msdn.microsoft.com/en-us/library/office/bb862071(v=office.14).aspx

If you're not stuck using CAML queries, let me know what other options are available (such as AJAX or LINQ to SharePoint) and I'll try to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.