SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We tried to use DateTime.MaxValue to set empty value for DateTimeField and it works quite nice on our test environment, but we get following exception on some production farms.

Exception: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks, Stack Trace: at System.DateTime..ctor(Int64 ticks) at Microsoft.SharePoint.SPTimeZone.ConvertToUTC(DateTime date, UInt16 tzid) at Microsoft.SharePoint.WebControls.DateTimeField.set_Value(Object value)

Can anyone suggest how we can workaround this?

share|improve this question

try handling it with IsDateEmpty property, while saving it. for e.g.

if (!yourDatecontrol.IsDateEmpty)
{
    item["Date"] = yourDatecontrol.SelectedDate;
}
else
{
    item["Date"] = null;
}

Call ClearSelection method for empty value.

yourDatecontrol.ClearSelection();
share|improve this answer

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.