我想检索两个日期 insql server R2 版本之间的日期。在这里,我有以下表 CategoryProductStoreMapping
{CategoryID------ProductID------Qty-------date-----
--- 3 -------- 12 -------- 7 ------ 2013-01-05
--- 6 -------- 22 -------- 14 ----- 2013-01-06
--- 8 -------- 11 -------- 9 ------ 2013-01-07 }
我想检索存储在“2013-01-05”和“2013-01-07”之间的日期中的数据我已经尝试过很多方式,比如
{SELECT *
FROM CategoryProductStoreMapping as RL
where
CONVERT(VARCHAR(20), RL.[Date],103) BETWEEN CONVERT(VARCHAR(20),'2013-01-05',103)
AND CONVERT(VARCHAR(20),'2013-01-07',103)}
我还尝试了以下语句来检索相同的内容:
{ SELECT *
FROM CategoryProductStoreMapping as RL
where RL.[Date]>='2013-01-05' and RL.[Date]<='2013-01-07'}
我也试过这个:
{ SELECT *
FROM CategoryProductStoreMapping as RL
where RL.[Date] between '2013-01-05' and '2013-01-07'}
代替 '' 我尝试了 ## 来定义 SQL;它是日期,但仍然没有检索到数据。通过这样做,我只能检索列名,但不能检索数据。