Using C# CSOM and this is SharePoint 2010 – I am attempting to pull the vale of a Date And a time field to my Winform.
If I type in the immediate window
listItem(“datetimefield”);
It will return
{7/22/2018 3:22:00 AM}
Date:
Day:
DayOfWeek:
DayOfYear:
Hour:
Kind:
Millisecond:
Minute:
Month:
Seconds:
Ticks:
TimeOfDay:
Year:
I want to pull the value from Date – what would be the syntax to do such?
EDIT
If it helps this is full syntax I attempted to use. I can connect fine and pull values for other field types, just not a Date and Time field type.
Public static void GetDateTimeData()
{
using (var ctx = new ClientContext(SPURL))
{
List list = web.Lists.GetByTitle(SPSite);
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml= strong.Format();
ListItemCollection items = list.GetItems(camlQuery);
ctx.Load(list);
ctx.Load(items);
ctx.ExecuteQuery();
foreach (ListItem listItem in items)
{
DateTime TargetSD = (dateTime)listItem("maindate");
string date = Convert.ToDateTime(listItem("maindate").ToString();
}
}
}