title: How can I add the current DateTime to a SQL Server CE datetime column?
body: <p>We have code that updates a SQL CE table like so:</p>
  
  <pre><code>if (!IsValidColumn("platypi", "playtpus_id"))
  {
      dynSQL = "ALTER TABLE platypi ADD playtpus_feed nvarchar(19)";
      dbconn.DBCommand(dynSQL,false);
  
      dynSQL = "UPDATE platypi SET playtpus_feed = 'Purina Platypus Chow'";
      dbconn.DBCommand(dynSQL,false);
  }
  </code></pre>
  
  <p>IOW, if the column does not exist, create it, and then set each playtpus_name val to an empty string.</p>
  
  <p>What about in the case of a timestamp column, though? </p>
  
  <p>Suppose each platypus has a barcode on its poison toe that gets scanned before it is shipped out to Mammals R Us, and so we want to add a "time_scanned" column like so:</p>
  
  <pre><code>if (!IsValidColumn("platypi", "time_scanned"))
  {
      dynSQL = "ALTER TABLE platypi ADD time_scanned datetime";
      dbconn.DBCommand(dynSQL,false);
  
      dynSQL = "UPDATE platypi SET time_scanned = '&lt;What here?&gt;'";
      dbconn.DBCommand(dynSQL,false);
  }
  </code></pre>
  
  <p>Assuming we want to put the current time in the UPDATE...SET line, what should it be? How can I add that?</p>
  
  <p>Based on <a href="http://technet.microsoft.com/en-us/library/aa275635(v=SQL.80).aspx" rel="nofollow">this</a>, where it says, "Valid year range 1753-9999; valid second range 0-59" for "SQL Server CE specifics," should I do something like:</p>
  
  <pre><code>DateTime dt = Now;
  dynSQL = String.Format("UPDATE platypi SET time_scanned = '{0}', dt.ToString()";
  </code></pre>
  
  <p>or...???</p>