Quantcast
Channel: SharePoint 2010 - General Discussions and Questions forum
Viewing all articles
Browse latest Browse all 17574

CAML Queries returns total count instead of count after executing query from sharepoint 2010 Library.

$
0
0

hi,

I am using  following code to get count from a Document library after performing a query to retrieve data for last 7 days,I executed the query in U2U CAML QUERY Builder it is giving correct results,but when its executed through visual studio 2010, its returning me the total count in library instead of count after executing the query,Code is given below

 

SPDocumentLibrary weeklyList = (SPDocumentLibrary)web.Lists["test"];

        

 SPQuery Query1 = new SPQuery();

          

  Query1 .Query = "<Query><Where><And><Geq><FieldRef Name='SubmissionDate' /><Value Type='DateTime'>[Today-7Day(s)]</Value></Geq><Leq><FieldRef Name='CompletionDate' /><Value Type='DateTime'>[Today-0Day(s)]</Value></Leq></And></Where></Query>";

           

            

 SPListItemCollection CountCollection = weeklyList.GetItems(Query1 )

 int weekCount = CountCollection .Count;

lblweek.Text = weekCount.ToString();

Any pointers will be helpful thanks in advance.


Viewing all articles
Browse latest Browse all 17574

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>