【问题标题】:DataView.RowFilter with timespan in c#C# 中具有时间跨度的 DataView.RowFilter
【发布时间】:2016-02-11 07:35:51
【问题描述】:

我无法使用时间跨度到特定时间进行行过滤。我不想要 linq thingie 的解决方案..

dv.RowFilter = "timeField = '11:00:00'";

有没有像数据时间那样代表时间的符号? 例如

dv.RowFilter = "datetimeField = #12/31/2002#";

【问题讨论】:

标签: c# dataview rowfilter


【解决方案1】:

根据以下链接上的帖子:
https://social.msdn.microsoft.com/Forums/en-US/079eb08f-80e2-4d3b-8b8c-8d2027fde370/timespan-data-type-in-datatableselect?forum=adodotnetdataset

将TimeSpan转换为字符串时为“PT11H???????????????”其中数字 11 是小时。我仍然不知道分钟和秒在字符串中的位置。

所以我的代码是这样写的

dv.RowFilter = "Convert(timeField, System.String) LIKE 'PT11H%'";

【讨论】:

    【解决方案2】:

    它会在位置 45 处遇到此异常“无法解释令牌 ':'。”

    听起来表达式应该是本地化的:

    dv.RowFilter = "timeField = '11.00.00'";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多