Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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());
share|improve this answer
    
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. –  Michael Binder Mar 21 '13 at 10:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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