Forum Discussion
CAML Query to filter library not working as expected
- Aug 11, 2022
Dear All, I used below format and it worked, thanks for your support... I am sharing below CAML code...
string Iso8601Today = XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Local);
_query.ViewXml = "<View><Query>" +
"<Where>" +"<Leq>" +
"<FieldRef Name='testDate'/>" +
"<Value IncludeTimeValue='FALSE' Type='DateTime'>"+Iso8601Today+"</Value>" +
"</Leq>" +
"</Where>" +
"<OrderBy><FieldRef Name ='Created' Ascending = 'True' /></OrderBy></Query></View>";I got the required result, please add your comment for more optimization ...
regards
Badar
I tried below after your comments but result is same , thanks for your reply..
_query.Query = "<View><Query>" +
"<Where><And>" +
"<Eq><FieldRef Name='Description0' /><Value Type='Text'>" + myParam.ToString() + "</Value></Eq>" +
"<Geq><FieldRef Name='Modified'/><Value IncludeTimeValue='FALSE' Type='DateTime'><Now /></Value></Geq>" +
"</And>" +
"</Where>" +
"<OrderBy><FieldRef Name ='Created' Ascending = 'True' /></OrderBy></Query></View>";
What is the type of Description0 field? if it's multiline of text then use below query.
<View>
<Query>
<Where>
<And>
<Eq>
<FieldRef Name='Description0' />
<Value Type='Note'>You Value</Value>
</Eq>
<Geq>
<FieldRef Name='Modified' />
<Value IncludeTimeValue='FALSE' Type='DateTime'>
<Now />
</Value>
</Geq>
</And>
</Where>
<OrderBy>
<FieldRef Name='Modified' Ascending='True' />
</OrderBy>
</Query>
</View>- badar_000Aug 08, 2022Copper Contributor
- kalpeshvaghelaAug 08, 2022Iron ContributorCould you share screen shot of your list or library and show which record is not being displayed according to condition because ideally query is correct and it should show result
- badar_000Aug 08, 2022Copper Contributor