I have a custom aspx form where I retrieve list items by filtering two values EventDate and EndDate. I have a realization but it returns nothing:

 DateTime eventDate = Convert.ToDateTime(properties.AfterProperties["EventDate"].ToString());
 DateTime endDate = Convert.ToDateTime(properties.AfterProperties["EndDate"].ToString());

SPSite site = new SPSite("http://local/");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["eRoom"];
SPQuery query = new SPQuery();
query.DatesInUtc = true;
query.Query = String.Format(
   "<Where>" +
        "<And>" +
                "<Geq><FieldRef Name='EventDate'/><Value Type='DateTime' IncludeTimeValue='True'StorageTZ='TRUE'>{0}</Value></Geq>" +
                "<Leq><FieldRef Name='EndDate'/><Value Type='DateTime' IncludeTimeValue='True' StorageTZ='TRUE'>{1}</Value></Leq>" +
        "</And>" +

SPListItemCollection itemColl = list.GetItems(query);

What is wrong?

  • No white space between StorageTZ and 'True' in the <Geq>. Use SPCamlQueryBuilder to debug your CAML query more quickly: spcamlqueryhelper.codeplex.com – Boland Nov 3 '14 at 8:01
  • @Boland the same thing – testimon123 Nov 3 '14 at 10:19
  • @testimon123 Did you find a solution to your problem in the meantime? – Slaven Semper Nov 7 '14 at 13:30

Your code works for me. You should double check eventDate and endDate parameter values. I've tested your code with DateTime columns with default values set during creation.


try with this:


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.