然后我有两个datetimepickers,用于From date和To。 我试图通过SQL获取它查询 Hello!I have datetime field in DB, which stores invoice dates (format is 7/15/2014 12:00:00 AM)Then I have two datetimepickers, for From date and To date.I am trying to get it through SQL queryWhere TRDate between @DT1 and @DT2 Order By TRRef DESC 问题是,如果我使用日期时间选择器选择7/15/2014,它不会显示第15个数据。为此,我需要选择第14位。 未选择包含日期? 谢谢The problem is, If I select 7/15/2014 using datetime picker, it does not show the data for 15th. For this I need to select 14th.Isn't selected date inclusive?Thanks推荐答案 如果您查看BETWEEN的W3Schools信息: http:/ /www.w3schools.com/sql/sql_between.asp [ ^ ] 您将在底部看到: 请注意,BETWEEN运算符可以产生不同的结果在不同的数据库中! 在某些数据库中,BETWEEN选择介于测试值之间和排除测试值的字段。 在其他数据库中,BETWEEN选择介于测试之间的字段值。 在其他数据库中,BETWEEN选择测试值之间的字段,包括第一个测试值和不包括最后一个测试值。 因此:检查数据库如何处理BETWE EN运营商! 由于我们不知道您使用的是哪个数据库,我们甚至无法发表评论!If you look at the W3Schools info for BETWEEN: http://www.w3schools.com/sql/sql_between.asp[^]You will see at the bottom: "Notice that the BETWEEN operator can produce different result in different databases!In some databases, BETWEEN selects fields that are between and excluding the test values.In other databases, BETWEEN selects fields that are between and including the test values.And in other databases, BETWEEN selects fields between the test values, including the first test value and excluding the last test value.Therefore: Check how your database treats the BETWEEN operator!"Since we don't know which DB you are using, we can't even begin to comment! Where TRDate between @DT1 and DATEADD(DD,1,@DT2) Order By TRRef DESC 试试这个Try this 这篇关于Sql Query不显示所选日期的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-10 04:14