Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, November 29, 2012

Real Time Logic Retrieving next 15 Days Due Date Tasks from Tasks List



DateTime str = (DateTime)DateTime.Today.AddDays(15);
            string strNewDate = str.Year + "-" + str.Month + "-" + str.Date.Day;
            SPWeb currentWeb = SPContext.Current.Web;
            SPList lst = currentWeb.Lists["Tasks"];
            SPQuery sQuery = new SPQuery();
            sQuery.Query = "<Where><Geq><FieldRef Name='DueDate' /><Value Type='DateTime'>"+strNewDate+"</Value></Geq></Where><OrderBy><FieldRef Name='DueDate' /></OrderBy>";
            SPListItemCollection myColl = lst.GetItems(sQuery);
            if (myColl.Count > 0)
            {
                dgvTasks.DataSource = myColl.GetDataTable();
                dgvTasks.DataBind();
            }

No comments:

Post a Comment