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

Are you wanting a WHERE clause example? If so, what database are you using?

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'

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))
      {
        conn.Open();
        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();
            dt.Load(dr);
            dataGridView1.DataSource = dt;
          }
        }
      }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.