Adhikar Patil

Adhikar Patil

  • NA
  • 481
  • 127.9k

I want filter dataset using two dates

Aug 2 2018 2:37 AM
dt2 = ds.Tables[0].Select().Where(p => (Convert.ToDateTime(p["SignupDate"]) >= Convert.ToDateTime(txtFMinDate.Text)) && (Convert.ToDateTime(p["SignupDate"]) <= Convert.ToDateTime(txtFMaxDate.Text))).CopyToDataTable();
 
I want Above statement in the below format(This is not working). 
 
DataView dataView = ds.Tables[0].DefaultView;
string where="";
where = "SignupDate >='" + Convert.ToDateTime(txtFMinDate.Text) + "'" + " AND SignupDate <='" + Convert.ToDateTime(txtFMaxDate.Text) + "'";
dataView.RowFilter = where;
DataTable dt = dataView.ToTable();
Filterds.Tables.Add(dt);
 
So, i want the perfect format.

Answers (4)