Feb 24 2020 01:32 AM
Hi there,
I have a question is when I put a data into a List such as Title and Login time by programming. then I found the Date time is NOT the same. If I want to use the Login Time to find out the information, how should I do when I use CAML
Feb 24 2020 05:58 AM
Hi @Will # _________ H ,
Can you elaborate how did you update the data? And specifically, are you referring to the extra fraction=seconds in the time?
Thanks,
Riwut Libinuko
Feb 24 2020 07:49 AM
I intercept user login time and put it into the List A, when user logs into the SharePoint. I found the data (Login Time) will be converted to UTC Date Time and saved it into the Database. the Login time on the List View will be Local Time as the shown below. But when I use the same User ID and Login Time to search by CAML language, I cannot found anything. I also list out my source code for you to look at. so do you have any idea on it ?? Thanks
DateTime dateTime = DateTime.UtcNow;
if (sPList != null)
{
SPListItemCollection listItemCollection = sPList.Items;
SPListItem sPListItem = listItemCollection.Add();
sPListItem["Title"] = "0#.w|litwareinc\\administrator";
sPListItem["Login_x0020_Time"] = System.TimeZone.CurrentTimeZone.ToLocalTime(dateTime);
sPListItem["UTC"] = dateTime;
sPListItem.SystemUpdate();
SPQuery sPQuery = new SPQuery();
sPQuery.Query = @"<Where><And><Eq><FieldRef Name='Title' />" +
"<Value Type='Text'>0#.w|litwareinc\\administrator</Value></Eq>" +
"<Eq><FieldRef Name='Login_x0020_Time' /><Value IncludeTimeValue='true' Type='DateTime'>" + dateTime + "</Value></Eq>" +
"</And></Where>";
//sPQuery.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='Login_x0020_Time' />";
SPListItemCollection sPListItemCollection = sPList.GetItems(sPQuery);