I have a big problem. I am using KeywordQuery in server side code to return items from several lists with same contenttypeid. I have in those list some datetime columns. When i return the value from the keywordwquery search i get
3/2/2017 11:00:00 PM
But i saved 3/3/2017 as date in the list item! What is wrong here? Why am i receiving always the date - 1 hour from the search database and how can i correct this in my server side code?
This is my code:
SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(querySite));
using (KeywordQuery keywordQuery = new KeywordQuery(proxy))
{
try
{
keywordQuery.ResultsProvider = SearchProvider.Default;
keywordQuery.StartRow = 0;
keywordQuery.RowLimit = 9999;
keywordQuery.EnableStemming = false;
keywordQuery.TrimDuplicates = false;
keywordQuery.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
keywordQuery.KeywordInclusion = KeywordInclusion.AllKeywords;
keywordQuery.QueryText = "contentclass:\"STS_ListItem_Task\" NOT ContentTypeId:\"0x010800C140B62AF5566C4CBFC76C53B8D4DA94\"";
keywordQuery.SelectProperties.Add("Author");
keywordQuery.SelectProperties.Add("AssignedTo");
keywordQuery.SelectProperties.Add("DueDate");
keywordQuery.SelectProperties.Add("StartDate");
keywordQuery.SelectProperties.Add("path");
keywordQuery.SelectProperties.Add("title");
SearchExecutor executor = new SearchExecutor();
ResultTableCollection resultTableCollection = executor.ExecuteQuery(keywordQuery);
var resultTables = resultTableCollection.Filter("TableType", KnownTableTypes.RelevantResults);
ResultTable resultTable = resultTableCollection.FirstOrDefault();
if (resultTable.Table.Rows.Count > 0)
{
...
}
}
catch (Exception ex)
{
}
}
I believe it's the time zone shift that comes into play here. Check which time is local and which is UTC.