title: caml query not working properly in sharepoint online
body: <p>I need to get list items which is older than say 7 days and delete them. I tried using caml query and it worked well in sharepoint 2010 but when I tried to use the same in Sharepoint Online, its getting all list items and deleting it regardless of the condition.</p>
  
  <pre><code>    public static bool removeOldEntries(string listName, int offset)
      {
          bool successFlag = true;
          try
          {
              using (var context = new ClientContext(siteURL))
              {
                  SecureString password = ToSecureString(pwd);
                  context.Credentials = new SharePointOnlineCredentials(userName, password);
                  Web web = context.Web;
                  var list = context.Web.Lists.GetByTitle(listName);
                  if (list != null)
                  {
                      CamlQuery camlQuery = new CamlQuery();
                      camlQuery.ViewXml = "&lt;Where&gt;&lt;Leq&gt;&lt;FieldRef Name='Modified'/&gt;&lt;Value Type='DateTime'&gt;&lt;Today OffsetDays='-" + offset + "'/&gt;&lt;/Value&gt;&lt;/Leq&gt;&lt;/Where&gt;";
                      ListItemCollection collListItem = list.GetItems(camlQuery);
                      context.Load(collListItem, items =&gt; items.Include(
                                           item =&gt; item["ID"]));
                      context.ExecuteQuery();
                      if (collListItem.Count &gt; 0)
                      {
                          foreach (ListItem oListItem in collListItem)
                          {
                              ListItem itemToDelete = list.GetItemById(int.Parse(oListItem["ID"].ToString()));
                              itemToDelete.DeleteObject();
                              context.ExecuteQuery();
                          }
                      }
                  }
              }
          }
          catch (Exception ex)
          {
              successFlag = false;
          }
          return successFlag;
      }
  </code></pre>
  
  <p>Thanks in advance for any help.</p>