Grid View Problems date time problem
d = DateTime.Now.ToString("dd/mm/yyyy");
cmdd1 = new SqlCommand(" ", conn);
cmdd1.CommandText = "select * from today where '" +
"@date"+
"' between fdate and tdate order by id desc ";
cmdd1.Parameters.AddWithValue("@date", Convert.ToDateTime(d));
SqlDataAdapter adapter1 = new SqlDataAdapter(cmdd1);
// Fill the DataSet.
DataSet ds1 = new DataSet();
adapter1.Fill(ds1, "today");
// Perform the binding.
GridView1.DataSource = ds1;
GridView1.DataBind();
in which fdate and tdate in datetime database plz it is not working
Gomathi PalaniswamyPosted Aug 4, 2010, 7:45 AM
The below coding will help if you save the values in tostring()
string d;
d = dateTimePicker1.Value.ToShortDateString() + " 00:00:00".ToString();
string d1;
d1 = dateTimePicker2.Value.ToShortDateString() + " 23:59:59".ToString();
select command:
select * from today where date between''+d+"'and'"+d1+"'
With Regards,
Gomathi.P