如何阻止 BindingSource.Filter 中的月份和日期发生变化?

How to stop the Month and Day from changing in the BindingSource.Filter?

这是我的 BindingSource.Filter

的代码
 Dim FilterStartMonth As Date = DateTimePickerTodaysDateTime.Value.Date
 Dim Filter2MonthsBack As Date = DateTimePickerTodaysDateTime.Value.AddMonths(-2).Date
 ClockInTimesBindingSource.Filter = "EmployeeID = " & ComboBoxOfficeEmployeeFilter.SelectedValue & " and Date <= '" & Filter2MonthsBack & "' and Date >= '" & FilterStartMonth & "'"

当我在它运行时逐步浏览它时,这些值是:

Filter2MonthsBack = 1/2/2017 12:00:00 上午

FilterStartMonth = 3/2/2017 12:00:00 上午

这是我想要的,但是 BindingSource.Filter 显示:

ClockInTimesBindingSource.Filter = "EmployeeID = 49 and Date <= '02/01/2017' and Date >= '02/03/2017'"

我不明白为什么要调换月份和日期??

如有任何帮助,我们将不胜感激。

我试过使用 .ToString("d") 但它仍然在过滤器字符串中变化。

您的查询是:

filter where the date is <= Jan 2, 2017 AND date is >= Mar 2, 2017

查询有效,因为那是不可能的。

你可能想改变等式:

" and Date >= '" & Filter2MonthsBack & "' and Date <= '" & FilterStartMonth & "'"