title: How to get timestamp with milliseconds while retrieving from SQL Server?
body: <p>In a SQL Server database timestamps are added with milliseconds. But while retrieving, milliseconds are not begin returned, i.e. if the timestamp is <code>2012-04-23 15:03:35.345 PM</code>, when being retrieved, I get only <code>2012-04-23 15:03:35.000 PM</code>. I used the following code for retrieving the data:</p>
  
  <pre><code>query = "Select * from database";
  _cmd = new SqlCommand(query, _con);
  
  SqlDataAdapter da = new SqlDataAdapter(_cmd);
  DataTable dt = new DataTable();
  da.Fill(dt);
  
  foreach (DataRow dr in dt.Rows)
  {
      string str = Convert.ToDateTime(dr[0].ToString()).ToString("yyyy-MM-ddhh:mm:ss.fff");
      dt[0] = str;
  }
  </code></pre>
  
  <p>How can I get the milliseconds also?</p>