I have a CAML query where I am getting records between a date range for a sharepoint 2010 list through an asmx web method call. It looks like this
<Query><Where><And><Geq><FieldRef Name=\"ows_Created\" /><Value IncludeTimeValue=\"TRUE\" Type=\"DateTime\">2013-01-01T15:55:52Z</Value></Geq><Leq><FieldRef Name=\"ows_Created\" /><Value IncludeTimeValue=\"TRUE\" Type=\"DateTime\">2013-10-22T15:56:29Z</Value></Leq></And></Where></Query>
However, whenever I try adding this as a parameter to the GetListItems webmethod, it's almost as if it completely disregards the query. It returns the first 30 records each time with the date lying outside the range. Here is what my code looks like. Why is it not taking into account my CAML query?
var client = new inq.Lists();
client.Credentials = System.Net.CredentialCache.DefaultCredentials;
XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
XmlDocument xmldocs = new XmlDocument();
XmlNode ndQuery = xmldocs.CreateNode(XmlNodeType.Element, "Query", "");
ndQuery.InnerXml = "<Query><Where><And><Geq><FieldRef Name=\"ows_Created\" /><Value IncludeTimeValue=\"TRUE\" Type=\"DateTime\">2013-01-01T15:55:52Z</Value></Geq><Leq><FieldRef Name=\"ows_Created\" /><Value IncludeTimeValue=\"TRUE\" Type=\"DateTime\">2013-10-22T15:56:29Z</Value></Leq></And></Where></Query>";
viewFields.InnerXml = "";
queryOptions.InnerXml = "";
System.Xml.XmlNode nodeListItems = client.GetListItems(guid, viewid, ndQuery, viewFields, null, queryOptions, null);