I need to fetch records in to gridview based on fromdate and todate using c#,plzzz help asap

Use BETWEEN caluse - BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression.

SELECT * FROM TableName Where TestDate 
  BETWEEN '01/01/2009' AND '01/31/2009'

Edited 7 Years Ago by __avd: n/a

Here is another example of MSSQL using the between operater with parameterized SQL:

private void button2_Click(object sender, EventArgs e)
      const string connStr = "Data Source=apex2006sql;Initial Catalog=Leather;Integrated Security=True;";
      const string query = "Select * From Invoice Where (InHomeDate BETWEEN @Date1 and @Date2)";
      using (SqlConnection conn = new SqlConnection(connStr))
        using (SqlCommand cmd = new SqlCommand(query, conn))
          cmd.Parameters.Add(new SqlParameter("@Date1", SqlDbType.DateTime)).Value = DateTime.Today.AddDays(-180);
          cmd.Parameters.Add(new SqlParameter("@Date2", SqlDbType.DateTime)).Value = DateTime.Today;
          using (SqlDataReader dr = cmd.ExecuteReader())
            DataTable dt = new DataTable();
            dataGridView1.DataSource = dt;
This question has already been answered. Start a new discussion instead.