我有一个查询条件是  rece_date<='2006-09-17' and rece_date>='2006-09-17'但是相关记录出不来?这么查询出来的记录应该是  2006-09-17  这天的记录才对啊?但是为什么没有记录呢?

解决方案 »

  1.   


    declare @s table(rece_date datetime)
    insert into @s(rece_date)
    select '2006-09-17'
    union all select '2006-09-18'
    union all select '2006-09-19'
    union all select '2006-09-16'select rece_date 
    from @s
    where rece_date<='2006-09-17' and rece_date>='2006-09-17'结果:(所影响的行数为 4 行)rece_date                                              
    ------------------------------------------------------ 
    2006-09-17 00:00:00.000(所影响的行数为 1 行)
      

  2.   

    select * from abc where rece_date<='2006-09-17' and rece_date>='2006-09-17'
    这样写能够查询出来记录嘛?我刚才用这个查询.但是没有记录出来?我也纳闷..
    我是新手,请指教...
      

  3.   

    但是我查询select * from abc where rece_date<='2006-09-17' and rece_date>='2006-09-18'的时候   2006-09-017的记录就会出来.
      

  4.   

    '2006-09-17' 这种格式代表的是'2006-09-17 00:00:00.000'这个时刻
    要查2006-09-17这一天的记录需要使用BETWEEN '2006-09-17' and '2006-09-18'来求
      

  5.   

    主  题:  一个简单的问题.是人都知道!  
    作  者:  makent (说好不笑)        Blog  
    楼主的意思是说,楼主不...
      

  6.   

    create table test
    (
    dates datetime
    )
    insert test
    select '2006-09-20 10:00' union all
    select '2006-09-20'
    select * from testselect * from test where dates>='2006-09-20' and dates<='2006-09-20'
    drop table test
      

  7.   

    因為你的時間2006-9-17後面肯定還有具體的時間, 而你的判斷條件where rece_date<='2006-09-17' and rece_date>='2006-09-17' 只包括2006-9-17和2006-9-17 00:00:00.所以你查不到
      

  8.   

    rece_date<='2006-09-17' and rece_date>='2006-09-17'
    你的时间(没有分小时)改为这样
    rece_date between '2006-09-17 00:00:00' and '2006-09-17 23:59:59'

    rece_date<='2006-09-17 00:00:00'and rece_date>='2006-09-17 23:59:59'
      

  9.   

    回复人:makent(说好不笑) ( 一级(初级)) 信誉:100  2006-09-20 10:15:00 
    但是我查询select * from abc where rece_date<='2006-09-17' and rece_date>='2006-09-18'的时候 2006-09-017的记录就会出来.
    ---------------------
    我对楼主的这个说法感到好奇。
      

  10.   

    請用  datediff(dd,convert(smalldatetime,'2006-09-17',120),rece_date)>=0
          AND datediff(dd,convert(smalldatetime,'2006-09-17',120),rece_date)<=0
      

  11.   

    select * from  TableName where rece_date between '2006-09-17'  and '2006-09-17' 

    select * from  TableName where convert(varchar(10),rece_date,120) between '2006-09-17'  and '2006-09-17'