title: Get the string data from database and convert it into date object in the query
body: <p>I am developing an ATM software in which I want to get report by entering the start date and end date. The date is saving in my table is in the form of string <code>dd/MM/yyyy</code>. I am trying the following code and getting the exception of incorrect syntax.</p>
  
  <pre><code>public DataTable getReportByDate(DateTime startDate, DateTime endDate)
  {
     try
     {
        DataTable table = new DataTable();
  
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
           SqlDataAdapter dataAdapter = new SqlDataAdapter("Select * from [Transaction] Where CAST(CurrDate AS Date) &gt;=" + startDate + " AND CAST(CurrDate AS Date) &lt;=" + endDate + ";", connectionString);
  
           // Create a command builder to generate SQL update, insert, and
           // delete commands based on selectCommand. These are used to
           // update the database.
           SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
  
           // Populate a new data table and bind it to the BindingSource.
           table.Locale = System.Globalization.CultureInfo.InvariantCulture;
           dataAdapter.Fill(table);
        }
        return table;
     }
     catch (Exception e)
     {
         return null;
     }
  }
  </code></pre>
  
  <p>Please help me.</p>
  
  <p>Regards</p>