Question

I have a dataview which has two columns. A and B each column has a date in it of type DateTime.

I would like to filter the dataview to only show rows where dates in A are greater than dates in B plus 6 months

A > (B+6months)

Here is what I have tried with no success.

DataView.RowFilter = "A > System.DateTime(B).AddMonths(6)";

DataView.RowFilter = "A > B.AddMonths(6)";

I appreciated any help given.

Was it helpful?

Solution

I am not a C# expert, but I believe you can use Linq to create the DataView as follows:

DataTable dt = new DataTable("MyTable"); // example data container

...

DataView dv = (from d in dt.AsEnumerable() where ((DateTime)d["A"]) > ((DateTime)d["B"]).AddMonths(6) select d).AsDataView();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top