سؤال

I am creating a windows forms which loads list items from sharepoint client object model.

I am having issue with Date field which is giving +1 day or -1 day i.e if i have entered date as 5/5/2014 it gives 5/6/2014 or sometimes 5/4/2014.

_query.ViewXml = "<View><Query><Where>" +
               "<And><Geq><FieldRef Name='Effort_x0020_Date'/><Value IncludeTimeValue='FALSE' Type='DateTime'>" + conStartDate + "</Value></Geq>" +
                    "<And><Leq><FieldRef Name='Effort_x0020_Date'/><Value IncludeTimeValue='FALSE' Type='DateTime'>" + conEndDate + "</Value></Leq>" +
                    "<Eq><FieldRef Name='Author' LookupId=’TRUE’/><Value Type=’Text’>" + UserID + "</Value></Eq></And></And></Where>" +
                    "<GroupBy  Collapse='TRUE'><FieldRef Name='WBS_x0020_Code'/></GroupBy></Query><RowLimit>25</RowLimit></View>";
SP.ListItemCollection _listitems = list.GetItems(_query);
clientcontext.ExecuteQuery();

After executing this if i use the below code it works properly but takes lot of time.

 foreach(ListItem item in _listitems) {
     DateTime start = ((DateTime) item["Effort_x0020_Date"]);
     ClientResult < string > result = Utility.FormatDateTime(clientcontext, clientcontext.Web, start, DateTimeFormat.DateTime);
     clientcontext.ExecuteQuery();
     DateTime rightStart = Convert.ToDateTime(result.Value, new CultureInfo((int) web.Language));
     //item["Effort_x0020_Date"] = rightStart;
 }

Somehow i want an alternate way by which this could be done faster so that everytime connecting to sharepoint is avoided.

هل كانت مفيدة؟

المحلول

I resolved the issue by putting

_query.DatesInUtc=false.

It worked!!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top