title: How to convert string to a DateTime in C#?
body: <p>is it possible to convert a <code>string</code> (date stored as <code>varchar</code> in database) to <code>datetime</code> in c#?</p>
  
  <p>eg. i'm having a table which stores dates as varchar and it stores values as example</p>
  
  <p><code>01/21/14 11:42:36 PM</code></p>
  
  <p>i want to get the result in the format <code>yyyy-mm-dd</code></p>
  
  <p>i tried,</p>
  
  <pre><code>CultureInfo enUS = new CultureInfo("en-US");
  DateTime d;
  DateTime.TryParseExact("01/21/14 11:42:36 PM", "yyyy-mm-dd", enUS, DateTimeStyles.None, out d);
  </code></pre>
  
  <p><strong>also tried below steps:</strong></p>
  
  <pre><code>CultureInfo enUS = new CultureInfo("en-US");
  DateTime d = Convert.ToDateTime("01/21/14 11:42:36 PM");
  string dt = Convert.ToString(d);
  DateTime.TryParseExact(dt, "MM/dd/yy hh:mm:ss tt", enUS, DateTimeStyles.None, out d);
  var output = d.ToString("yyyy-mm-dd");
  </code></pre>
  
  <p>getting value <code>1/1/0001 12:00..</code> in <code>dt</code>.</p>
  
  <p>what could be the reason? also in which format do i need to pass the date (<code>dt</code> in above case) to <code>DateTime.TryParseExact(..)</code></p>