title: How to use 2 between in a SqlCommand?
body: <p>I'm trying to get data from a SQL Server database between two dates and two times of the day but I don't know how to use two <code>between</code> in a <code>SqlCommand</code>.</p>
  
  <p>This is what I've tried</p>
  
  <pre><code>public void getData()
  {
      SqlCommand SelectSpecificDataTL = new SqlCommand("Select * from cash where Date between @InitialDate and @FinalDate and where Time between @InitialTime and @FinalTime", database.cash);
  
      database.cash.Open();
  
      SelectSpecificDataTL.Parameters.AddWithValue("@InitialDate", dateTimePickerIDate.Value);
      SelectSpecificDataTL.Parameters.AddWithValue("@FinalDate", dateTimePickerFDate.Value);
      SelectSpecificDataTL.Parameters.AddWithValue("@InitialTime",Convert.ToDateTime(txtInitialTime.Text));
      SelectSpecificDataTL.Parameters.AddWithValue("@FinalTime", Convert.ToDateTime(txtFinalTime.Text));
  
      SqlDataAdapter SpecificData = new SqlDataAdapter(SelectSpecificDataTL);
      DataTable data = new DataTable();
      SpecificData.Fill(data);
      database.cash.Close();
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'where'</p>
  </blockquote>