比较DataView.RowFilter日期? [英] Compare dates in DataView.RowFilter?

查看:554
本文介绍了比较DataView.RowFilter日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我抓我的头了东西,而愚蠢的但显然很难。

I am scratching my head over something rather stupid yet apparently difficult.

DataView dvFormula = dsFormula.Tables[0].DefaultView;
dvFormula.RowFilter = "'" + startDate.ToString("yyyyMMdd") + "' < EndDate OR EndDate = '19000101'";
dvFormula.Sort = "FromDate ASC";



结果是这样的:

The result is this:

无法执行'<'。在System.String和System.DateTime的操作

Cannot perform '<' operation on System.String and System.DateTime.

请告诉我是什么解决这一问题将是最好的方式。

Please tell me what the best way to solve this problem would be.

非常感谢!

推荐答案

您需要包装与#您的日期,而不是​​单引号。

You need to wrap your dates with #, not apostrophes.

dvFormula.RowFilter =#+ startDate.ToString(MM / DD / YYYY)+ #&下;结束日期或结束日期=#1/1/1900年#;

dvFormula.RowFilter = "#" + startDate.ToString("MM/dd/yyyy") + "# < EndDate OR EndDate = #1/1/1900#";

这篇关于比较DataView.RowFilter日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆