Showing posts with label CAML Query. Show all posts
Showing posts with label CAML Query. Show all posts

Wednesday, March 2, 2016

How to retrieving next 7 Days Due Date Tasks from SharePoint List

C# Coding:


DateTime strdate = (DateTime)DateTime.Today.AddDays(7);
            string strgetDate = strdate.Year + "-" + strdate.Month + "-" + strdate.Date.Day;

SPWeb currentWeb = SPContext.Current.Web;
            SPList lst = currentWeb.Lists["Projects"];
            SPQuery sQuery = new SPQuery();
            sQuery.Query = "<Where><Geq><FieldRef Name='DueDate' /><Value Type='DateTime'>"+strgetDate+"</Value></Geq></Where><OrderBy><FieldRef Name='DueDate' /></OrderBy>";
            SPListItemCollection myColl = lst.GetItems(sQuery);
            if (myColl.Count > 0)
            {
                grdBind.DataSource = myColl.GetDataTable();
                grdBind.DataBind();
            }

Tuesday, February 9, 2016

Datetime CAML query not working

<Where>

  <Leq>
   <FieldRef Name ='" + internalEndDate + "'/>
   <Value Type ='DateTime'>" + System.DateTime.Now.AddDays(7) + "</Value>
  </Leq>


 </Where>

Current Date
<Where>

  <Leq>
   <FieldRef Name ='" + internalEndDate + "'/>
   <Value Type ='DateTime'>" + System.DateTime.Now+ "</Value>
  </Leq>


 </Where>