Set DateTime in ItemAdding/ItemAddedWhen trying to set a date field's value in an event receiver I get the following error (from the SP log file).  How should I be setting the date field's value?<br><br><strong>Field in List Definition:<br></strong><font color="#0000ff" size=2>&lt;</font><font color="#a31515" size=2>Field </font><font color="#ff0000" size=2>ID</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>{...}</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Name</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>DateField</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Type</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>DateTime</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Format</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>DateTime</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    StorageTZ</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>UTC</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    DisplayName</font><font color="#0000ff" size=2>=</font><font size=2>&quot;<font color="#0000ff" size=2>Date Field</font></font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Description</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>...</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    SourceID</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>http://schemas.microsoft.com/sharepoint/v3</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Required</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>FALSE</font><font size=2>&quot;</font><font color="#0000ff" size=2>/&gt;</font><br><br><strong>ItemAdding() snippet:<br></strong><font size=2>properties.AfterProperties[fields[</font><font color="#a31515" size=2>&quot;Date Field&quot;</font><font size=2>].InternalName] = </font><font color="#2b91af" size=2>SPUtility</font><font size=2>.CreateISO8601DateTimeFromSystemDateTime(</font><font color="#2b91af" size=2>DateTime</font><font size=2>.Now).ToString();<br></font><br><strong>A trace of what SPUtility returns:</strong><br>2008-09-30T10:53:28Z<br><br><strong>Error in log:</strong><br>Error loading and running event receiver &lt;...&gt;.&lt;...&gt;ListItemHandler in &lt;...&gt;, Version=1.0.0.0, Culture=neutral, PublicKeyToken=&lt;...&gt;. Additional information is below.  : <strong>Value does not fall within the expected range.</strong>© 2009 Microsoft Corporation. All rights reserved.Wed, 22 Oct 2008 15:19:06 Z200e172f-0a1c-4f81-bf38-a7077c392b5fhttp://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/200e172f-0a1c-4f81-bf38-a7077c392b5f#200e172f-0a1c-4f81-bf38-a7077c392b5fhttp://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/200e172f-0a1c-4f81-bf38-a7077c392b5f#200e172f-0a1c-4f81-bf38-a7077c392b5fAggieEngineer2khttp://social.msdn.microsoft.com/Profile/en-US/?user=AggieEngineer2kSet DateTime in ItemAdding/ItemAddedWhen trying to set a date field's value in an event receiver I get the following error (from the SP log file).  How should I be setting the date field's value?<br><br><strong>Field in List Definition:<br></strong><font color="#0000ff" size=2>&lt;</font><font color="#a31515" size=2>Field </font><font color="#ff0000" size=2>ID</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>{...}</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Name</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>DateField</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Type</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>DateTime</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Format</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>DateTime</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    StorageTZ</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>UTC</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    DisplayName</font><font color="#0000ff" size=2>=</font><font size=2>&quot;<font color="#0000ff" size=2>Date Field</font></font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Description</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>...</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    SourceID</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>http://schemas.microsoft.com/sharepoint/v3</font><font size=2>&quot;<br></font><font color="#ff0000" size=2>    Required</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>FALSE</font><font size=2>&quot;</font><font color="#0000ff" size=2>/&gt;</font><br><br><strong>ItemAdding() snippet:<br></strong><font size=2>properties.AfterProperties[fields[</font><font color="#a31515" size=2>&quot;Date Field&quot;</font><font size=2>].InternalName] = </font><font color="#2b91af" size=2>SPUtility</font><font size=2>.CreateISO8601DateTimeFromSystemDateTime(</font><font color="#2b91af" size=2>DateTime</font><font size=2>.Now).ToString();<br></font><br><strong>A trace of what SPUtility returns:</strong><br>2008-09-30T10:53:28Z<br><br><strong>Error in log:</strong><br>Error loading and running event receiver &lt;...&gt;.&lt;...&gt;ListItemHandler in &lt;...&gt;, Version=1.0.0.0, Culture=neutral, PublicKeyToken=&lt;...&gt;. Additional information is below.  : <strong>Value does not fall within the expected range.</strong>Tue, 30 Sep 2008 16:09:12 Z2008-09-30T16:09:12Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/200e172f-0a1c-4f81-bf38-a7077c392b5f#50b9f7d6-df5f-4480-86e0-4024e8ef5ad3http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/200e172f-0a1c-4f81-bf38-a7077c392b5f#50b9f7d6-df5f-4480-86e0-4024e8ef5ad3Michael Washam - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Michael%20Washam%20-%20MSFTSet DateTime in ItemAdding/ItemAdded It looks right.. Add a breakpoint in your ItemAdding event.<br><br>Then add:<br><font size=2>properties.AfterProperties[&quot;Date Field&quot;] <br>and<br>fields[&quot;Date Field&quot;].InternalName<br><br><font size=2>to your watch list to see which one is broken.<br></font><br><br><br></font><hr size="1" align="left" width="25%">Posting is provided &quot;AS IS&quot; with no warranties, and confers no rights.Tue, 30 Sep 2008 18:14:13 Z2008-09-30T18:14:13Zhttp://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/200e172f-0a1c-4f81-bf38-a7077c392b5f#b0931b56-27a3-4af4-80aa-a7d50c92c263http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/200e172f-0a1c-4f81-bf38-a7077c392b5f#b0931b56-27a3-4af4-80aa-a7d50c92c263Rafael Mascarenhashttp://social.msdn.microsoft.com/Profile/en-US/?user=Rafael%20MascarenhasSet DateTime in ItemAdding/ItemAdded You're setting your property as a string it should  be set as Date Time.<br><br>Hope it helps,<br><br><br>RafaelTue, 30 Sep 2008 19:08:11 Z2008-09-30T19:08:11Z