1
Answer

Grid View Problems date time problem

vipin saini

vipin saini

14y
1.5k
1

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
Answers (1)
0
Gomathi Palaniswamy

Gomathi Palaniswamy

NA 3.8k 1.5m 14y
Hi Friend,

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

Next Recommended Forum