title: Date formats .NET to mysql
body: <p>I'm pulling date values out of mysql and displaying them in locally used format. See below:</p>
  
  <p>I have this datetime value <code>2012-11-01 08:00:00</code> ... yyyy-MM-dd HH:mm:ss  </p>
  
  <p>I need this to appear as <code>01-11-2012 08:00:00</code> ... dd-MM-yyyy HH:mm:ss</p>
  
  <p>I can do this simply enough as follows:</p>
  
  <pre><code>Dim dr As MySqlDataReader = cmd.ExecuteReader(sql)
  
  If dr.Read()
      Dim mydate As DateTime = dr("date_column")
  
      txtDate.Text = mydate.ToString("dd-MM-yyyy") &amp; " " &amp; mydate.ToString("HH:mm:ss")
  End If
  </code></pre>
  
  <p>This works well enough, but my problem is that if I want to update the record from this textbox, I can't use this format for the date because mysql complains about an error (object out of range or something).</p>
  
  <p>So what I need to do now is to convert this back to yyyy-MM-dd. The difficulty here is that .NET will automatically assume my <code>dd</code> value should be the <code>MM</code> value and vice versa.</p>
  
  <p>This results in a value of <code>01-11-2012</code> writing into the database as <code>11-01-2012</code>.</p>
  
  <p>How can I reformat the date for insert/update into the database while maintaining the integrity of the date that's being used here?</p>
  
  <p>Thanks in advance</p>