tags:

views:

123

answers:

1

is it possible to set a DateTime filed to be null/empty when calling UpdateListItems? I can set the field to a date value, but not set it to be empty.

A: 

Yes, it's possible.

I have tested with both a required and non-required datefield and setting the field to null works.

using (SPSite site = new SPSite("http://intranet"))
{
  using (SPWeb web = site.OpenWeb("site"))
  {

    SPList list = web.Lists["MyCustomList"];

    SPListItem item = list.Items.Add();
    item["Title"] = "My Item";
    item["UpdateDate"] = null; 

    item.Update();
    list.Update();
  }
}
Magnus Johansson