title: Conversion failed when converting date and/or time from character string SQL Server 2016
body: <p>Hello so i have a these code that have you enter a year, a month, a day all string into a text field and then it will combine them to make one string and used a statement to make query convert this to date and inserting it and some other data into a database here is the code.</p>
  
  <pre><code>    int CustomerID = Integer.parseInt(txtCustomerID.getText());
      int CarID = Integer.parseInt(txtCarID.getText());
      String startdateyear = txtStartDateYear.getText();
      String startdatemonth = txtStartDateMonth.getText();
      String startdateday = txtStartDateDay.getText();
      String enddateyear = txtEndDateYear.getText();
      String enddatemonth = txtEndDateMonth.getText();
      String enddateday = txtEndDateDay.getText();
      String StartDate = startdateyear + startdatemonth + startdateday;
      String EndDate = enddateyear + enddatemonth + enddateday;
      int HiringPrice = Integer.parseInt(txtHiringPrice.getText());
      String Pay = txtPay.getText();
      carDA.insert(CustomerID, CarID, StartDate, EndDate, HiringPrice, Pay);/
  </code></pre>
  
  <p>This is the Insert Query:</p>
  
  <pre><code>stm.executeUpdate("INSERT INTO CarOrder VALUES (" + CarID +"," + CustomerID +",CONVERT(DATE," + "'" +StartDate+ "', 111), CONVERT(DATE," + "'" +EndDate+"', 111)," +HiringPrice+ "," +"'"+Pay+ "')");
  </code></pre>
  
  <p>When i run the program it throws this message:</p>
  
  <pre><code>Conversion failed when converting date and/or time from character string.
  </code></pre>
  
  <p>I cant seem to find out why it is doing this, if any one can help me i will be thankful.</p>