1

So i have a SPFieldDateTime, and its default value is set to (none), i.e. null. Now some people use this to sort for specific ListItems (like "time finished" -> sort fot not null items you get all unfinished items). People got quite used to it, built something around it, but now i have a problem: Some guys wrote something into this field even though they werent finished, now everything is broken, and i was asked to set those fields to null via powershell. No Problem i said, but now it is! You cannot set a SPFieldDateTime to null. Or can you?

$item["DateTimeField"] = $null;
$item["DateTimeField"] = "";

None of these work. Anybody got an idea?

edit: I wanna try something like $item.Fields["DateTimeField"].Delete() but that only deletes the Column from the whole list..

4

1 回答 1

3

您走在正确的道路上,您只需要在进行更改后更新项目。以下应该有效:

$item["DateTimeField"] = $null
$item.Update()
于 2012-11-15T19:23:59.387 回答