In my application I need to filter all matching records from date column in datatable
DataRow[] dr= dt.Select(
"date where date='" +
Convert.ToString(txtmonth.Text) + "' and '" +
Convert.ToString(txtyear.Text) + "'");
Here I'm getting error how can I filter based on month and year from datatable date column
int Month = Convert.ToDateTime(txtFromDate.Text).Month;
int Year= Convert.ToDateTime(txtFromDate.Text).Year;
var Query = from row in dt.AsEnumerable() //List
let date = row.Field<DateTime>("date")
where date.Month == Month && date.Year == Year
select row;
DataRow[] dr = Query.ToArray();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.