Get records from List Using CAML query by adding days no in Today

Sagarp
Posted by Sagarp under SharePoint category on | Points: 40 | Views : 4105
using (SPSite oSite = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList lstE = oWeb.Lists.TryGetList("MyList");
SPQuery qrGetItem= new SPQuery();
string dateStr = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today.AddDays(2));
qrGeTenqrItem.Query = "<Where><Eq><FieldRef Name='ExpectedDate' IncludeTimeValue='FALSE' /><Value Type='DateTime'>" + dateStr + "</Value></Eq></Where>";
SPListItemCollection colItems = lstE .GetItems(qrGetItem);

}
}

Comments or Responses

Login to post response