Sharepont Calendar Item from and To Date through C# code

C# code to get item between from and to dates in sharepoint calendar SPList CalendarList = oSPWeb.Lists["Calendar"]; DateTime DueDate = Convert.ToDateTime(TextBox1.Text); DateTime ToDate = Convert.ToDateTime(TextBox2.Text); //string DueDate1 = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DueDate); //WORKING // string query = String.Format("" + // "{0}", SPUtility.CreateISO8601DateTimeFromSystemDateTime(DueDate)); string query = String.Format(" " + "" + "" + "" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(DueDate) + "" + "" + "" + "" + "" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(ToDate) + "" + "" + " "); SPQuery spQuery = new SPQuery(); spQuery.Query = query; //spQuery .ViewFields = string.Concat( // "", // "", // "", // ""); //spQuery.ViewFieldsOnly = true; // Fetch only the data that we need. SPListItemCollection Calendaritemcol = CalendarList.GetItems(spQuery); int Countitems = Calendaritemcol.Count; if (Countitems > 0) { TextBox1.Text = "Item found" + Countitems.ToString(); } else { TextBox1.Text = "Not found"; } }

No comments:

Post a Comment

SPFX - HTTPClient - Curd Operations - SharePoint list.

  Create solution in the name of SpfxCrud. ISpfxCrudProps.ts export interface ISpfxCrudProps {   description : string ;     context : an...