1

I have a list based on a content type that inherits from events. This list has two relevant fields:

• Start Date
• End Date

I add a new item to the list, setting the start time to 3:00pm and the end time to 3:05pm and then save the event.

When I click edit on the same event, SharePoint now shows the start time as being 12:00am. SharePoint seems only to be saving the date component of Start Date, but it saves the date and time component of End Date. Why is this?

1 Answer 1

0

In Event Content Type fields Start Time and End Time are both declared with Format as DateTime .

Start Time and End Time fields are dependent on the field All Day Event

All Day Event is unchecked

date & time could be specified for Start Time and End Time fields

All Day Event is checked

in that case only date part could be specified in form for Start Time and End Time fields. The following code demonstrates how time part is updated when All Day Event is checked

ListItem["StartDate"] = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0, (System.Globalization.Calendar) new GregorianCalendar());
ListItem["EndDate"] = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 0, (System.Globalization.Calendar) new GregorianCalendar());
1
  • The problem turned out to be due to the Template I used to create the List. I was setting it up originally using the SPListTemplateType.GenericList but I should have been using the SPListTemplateType.Events. When I use the latter, and I openSharePoint Manager to observe the Fields belonging to the List, the SchemaXml showed the following for StartDate: <FieldRefs> <FieldRef Name="fAllDayEvent" RefType="AllDayEvent" /> </FieldRefs> Whereas before, using the generic template, there was no field reference to the All Day Event, which is why my dates were changing. Commented Mar 21, 2013 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.