I have the following code (a DataView that filtered by DateTime):
dv = new DataView(
dataTable1,
"DateTime >= '" + Convert.ToDateTime("7/5/2011 9:21:00 AM") + "'",
"ID ASC", DataViewRowState.CurrentRows);
My datatable1 consist of the following data in the DateTime column:
- A: “7/5/2011 9:20:59 AM”
- B: “7/5/2011 9:21:00 AM”
- C: “7/5/2011 9:21:01 AM”
- D: “7/5/2011 9:22:00 AM”
Supposedly, only A should get filtered.
But my code has A, B and C filtered as well, and only returns D.
What is wrong?
Try enclosing the date string with
#. For example: