title: Convert a DataGridView Cell Value into a DateTime
body: <p>I've been searching for some time now for this answer:</p>
  
  <p>I've got a datagridview that has a cell with dates, and I need to make the value in that cell a DateTime value that can go with my DateTimePicker</p>
  
  <p>So far I've done this, but it's not working, it gives me a System.FormatException (apparently it can't recognize the string as a DateTime, which sounds about right)</p>
  
  <p>This is the code in question:</p>
  
  <pre><code>int index = ReservationDataGridView.SelectedRows[0].Index;
  string date = ReservationDataGridView[0, 1].Value.ToString();
  DateTime test = DateTime.ParseExact(date, "dd/MM/yyyy - hh:mm tt", System.Globalization.CultureInfo.InvariantCulture);
  
  MessageBox.Show(test.ToString()
  </code></pre>
  
  <p>This is how my DateTimePicker is formatted:</p>
  
  <pre><code>ReservationDateTimePicker.Format = DateTimePickerFormat.Custom;
  ReservationDateTimePicker.CustomFormat = "dd/MM/yyyy - hh:mm tt";
  </code></pre>
  
  <p>And this is how the dates look in the DataGridView:</p>
  
  <p><img src="https://i.stack.imgur.com/RxnUi.png" alt="DataGridView"></p>
  
  <p>Any ideas on how I can convert the DataGridView's Date value into a DateTime that will fit into a DateTimePicker with that formaT?</p>