c# - CAML- WebService Sharepoint -
hello stackoverflow community
i got load of forum. though time couldn't find.
i made asp.net application , try use sharepoint webservice items of list.
so far succeed in getting whole list using caml request, have select items between 2 given dates
i found lot of around , i'm using method format iso 8601 date string :
private string formatdateforcaml(datetime thedate) { string result = thedate.tostring("yyyy-mm-ddthh:mm:ssz"); return result; }
and here caml request building :
system.xml.xmlelement query = xmldoc.createelement("query"); query.innerxml = "<where>"+ "<and>"+ "<geq>"+ "<fieldref name=\"startdate\" />"+ "<value type=\"datetime\" includetimevalue=\"true\">" + thestart + "</value>" + "</geq>"+ "<lt>" + "<fieldref name=\"enddate\" />" + "<value type=\"datetime\" includetimevalue=\"true\">" + theend+ "</value>" + "</lt>" + "</and>"+ "</where>";
i don't have error return query :
system.xml.xmlnode nodelistitems = listservice.getlistitems(listname, viewname, query, viewfields, rowlimit, queryoptions, null);
but list returned null though shoudn't
thanks help.
edit : succeed, problem came wrong request here proper version
system.xml.xmlelement query = xmldoc.createelement("query"); query.innerxml = "<where>"+ "<and>"+ "<geq>"+ "<fieldref name=\"startdate\" />"+ "<value type=\"datetime\" includetimevalue=\"true\">" + thestart + "</value>" + "</geq>"+ "<lt>" + "<fieldref name=\"startdate\" />" + "<value type=\"datetime\" includetimevalue=\"true\">" + theend+ "</value>" + "</lt>" + "</and>"+ "</where>";
thanks roqz used caml viewer,and problem : had compare start date !
thank both :)
in caml builder tool query similar yours return result should. query looks like:
<query> <where> <and> <geq> <fieldref name="created" /> <value includetimevalue="true" type="datetime">2013-04-01t19:35:49z</value> </geq> <lt> <fieldref name="modified" /><value includetimevalue="true" type="datetime">2013-05-24t19:36:46z</value> </lt> </and> </where> </query>
but remember, if want use query in code not need surrounding tags. have checked date format correct? in example can't see "z" @ end.
Comments
Post a Comment