title: Using pymssql to insert datetime object into SQL Server
body: <p>How do I insert a datatime object using pymssql? I know that the SQL Server table is expecting a datetime object, let's say in position 3.  I've tried all three of these:</p>
  
  <pre><code>cursor.execute("INSERT INTO MyTable VALUES(1, 'Having Trouble', datetime.datetime.now())")
  cursor.execute("INSERT INTO MyTable VALUES(1, 'Having Trouble', 20130410)")
  cursor.execute("INSERT INTO MyTable VALUES(1, 'Having Trouble', '20130410')")
  cursor.execute("INSERT INTO MyTable VALUES(1, 'Having Trouble', GETDATE())")
  </code></pre>
  
  <p>and I get the same error each time:</p>
  
  <pre><code>OperationalError: (241, 'Conversion failed when converting date and/or time from character string.DB-Lib error message 241, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')
  </code></pre>
  
  <p>I've scoured the little documentation there is, and searched repeatedly.</p>
  
  <p><strong>EDIT:</strong> Secondary problem was a field-length problem. See the first comment on the accepted answer.</p>