DataView中的过滤日期时间不过滤分钟和秒
我有以下代码(按日期时间过滤的 DataView):
dv = new DataView(
dataTable1,
"DateTime >= '" + Convert.ToDateTime("7/5/2011 9:21:00 AM") + "'",
"ID ASC", DataViewRowState.CurrentRows);
我的 datatable1 在日期时间列中包含以下数据:
- A:“7/5/2011 9:20:59 AM”
- B:“7/5/2011 9 :21:00 上午"
- C: "7/5/2011 9:21:01 上午"
- D: "7/5/2011 9:22:00 上午"
据说,只有 A 应该被过滤。 但我的代码也过滤了A、B和C,并且只返回D。
怎么了?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个
Try this
尝试用
#
括住日期字符串。例如:Try enclosing the date string with
#
. For example:删除
convert.todatetime
。你可以试试这个
Remove the
convert.todatetime
.You can try this