title: How to convert a date string from "dd-MMM-yy" to "M/dd/yyyy hh:mm:ss tt"?
body: <p>I need to compare two date format strings: </p>
  
  <p><strong>dateString</strong> in "dd-MMM-yy" format</p>
  
  <p>with </p>
  
  <p><strong>referenceDateString</strong> in "M/dd/yyyy hh:mm:ss tt" format respectively.</p>
  
  <p>For that, I need to convert the <strong>dateString</strong> = "dd-MMM-yy" to "M/dd/yyyy hh:mm:ss tt". </p>
  
  <p>However, Got an error while trying to do that: </p>
  
  <blockquote>
    <p>"Error: string was not recognized as a valid datetime".</p>
  </blockquote>
  
  <p>The C# code I used given below.</p>
  
  <pre><code>string dateString = "19-Dec-14";
  string AsofDate = DateTime.ParseExact(dateString, "M/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
  </code></pre>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>In the actual code the <strong>dateString</strong> obtaining after reading a csv file which is supplied as "19-Dec-14", that's why it's in the string format.</p>
  
  <p>Please help, am pretty new to C#. Thanks.</p>