我正在使用vb.net Windows Form Application,我有两个datepicker,我想在两个日期之间进行过滤... 我试过这段代码:
Me.DBBindingSource.Filter = "[Data ardhjes] BETWEEN " & dtpDataArdhjes.Value.Date & " AND " & dtpDataArdhjesNE.Value.Date
我收到了这个错误:
其他信息:表达式包含不受支持的运算符 '之间'。
和其他一些代码,但它不起作用.. [数据ardhjes]在表中,dtpDataArdhjes是表中的datetimepicker 和dtpDataARdhjesNe只是一个dateTimepicker,我想在名为[Data Ardhjes]的同一列中的两个日期之间进行搜索 有什么建议吗?
答案 0 :(得分:1)
试试这个:
Me.DBBindingSource.Filter = "[Data ardhjes] BETWEEN " & dtpDataArdhjes.Value.ToString("#yyyy/MM/dd#") & "
AND " & dtpDataArdhjesNE.Value.ToString("#yyyy/MM/dd#")
答案 1 :(得分:0)
我得到了答案:
Me.DBBindingSource.Filter = String.Format("[Data ardhjes] >= #{0:M/dd/yyyy}# AND [Data ardhjes] <= #{1:M/dd/yyyy}#", _
dtpDataArdhjes.Value, _
dtpDataArdhjesNE.Value)
现在效果很好..