我使用SQL Server 2014,我尝试使用以下查询在同一张表中的两个日期之间进行选择,数据类型为nvarchar
,我执行了以下查询,它仅向我显示了三行('30/03/2015','30/04/2015','30/04/2015')
,但实际上('29/02/2015','30/03/2015','31/04/2015','30/04/2015','30/04/2015')
select RegisteredDate
from Student
where Student.RegisteredDate between convert(nvarchar, '30/01/2014', 103)
and convert(nvarchar, '30/04/2015', 103)
当我阅读其他答案和评论时,我建议您首先将“ RegisteredDate”的数据类型从“ nvarchar”更改为“ date”。其次,使用下面的标准代码“ yyyy-MM-dd”
select RegisteredDate
from Student
where Student.RegisteredDate between '2014-01-30' and '2015-04-30'
您将不需要任何转换,这就是我自己做的方式
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句