0
votes

I am trying to get hours from the DateandTime field of a sharepoint calendar listitem using sharepoint Object Model.

int starttime = Convert.ToInt32(item["Start Time"]);

Obviously which returns type error.

Please throw some light that how i can pick Time value from the field and convert to Int.

Thanks in advance.

1

1 Answers

0
votes

Try:

DateTime starttime = Convert.ToDateTime(item["Start Time"]);

From there, you have a number of time properties (Hour, Millisecond, Minute, Second) that are integers.