I'm trying to filter my DataView by date:
DataTable dt = GetTableData();
DataView dvEvents = dt.DefaultView;
dvEvents.RowFilter = "date > #" + DateTime.Now.ToString() + "#";
But I'm getting this error:
Cannot perform '>' operation on System.String and System.DateTime.
I've also tried DateTime.Now.ToString("MM/dd/yyyy")
, and I get the same error.
What am I doing wrong here?
If you are using string values you need to replace the #
with '
.
For example:
dvEvents.RowFilter = "date > '" + DateTime.Now.ToString() + "'";
See this reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With