code_junkie

Best way to parse DateTime to SQL server

Nov 13th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. System.Data.SqlClient.SqlException: Conversion failed when converting datetime from character string
  2.  
  3. DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fff")
  4.  
  5. DateTime.Now.ToString("c")
  6.  
  7. insert into testtable values ('2009-01-22T15:08:13')
Add Comment
Please, Sign In to add comment