简体   繁体   English

C#中具有时间跨度的DataView.RowFilter

[英]DataView.RowFilter with timespan in c#

I have trouble doing rowfilter with timespan to a specific time. 我在将rowfilter与时间跨度设置为特定时间时遇到麻烦。 I don't want solution with linq thingie.. 我不想用Linq Thingie解决。

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

Is there any symbol to represent time like in datatime? 是否有任何符号可以代表数据时间? eg 例如

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

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

when converting TimeSpan to string is "PT11H???????????????" 将TimeSpan转换为字符串时为“ PT11H ???????????????” Where the number 11 is the hour. 数字11是小时。 I'm still don't know where the minutes and seconds are placed in the string. 我仍然不知道分钟和秒在字符串中的位置。

so my code is written something like this 所以我的代码是这样写的

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

It'll hit this exception 'Cannot interpret token ':' at position 45.' 它将在位置45遇到此异常“无法解释令牌':'”。

It sounds like the expression is expected to be localized: 听起来该表达式应该是本地化的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM