select * from table where convert(varchar(10),date,120) = '2002-03-09';

解决方案 »

  1.   

    to: zhuzhichao(炎龙骑士团—索尔—破龙击)
    这样不能用索引,不好,应这样,能用索引
    select * from table where date>='2002-03-09' and date<'2002-03-10'
      

  2.   

    select * from table where date >= '2001-01-01' and date<'2001-01-02'
      

  3.   

    可以这样:
    select * from table where convert(varchar(10),date,120) = '2001-01-01'
    但是,若在date字段上有索引的的话,那么将用不到索引
    还可以这样
    select * from table where date >= '2001-01-01' and date<'2001-01-02'
    若在date字段上有索引的的话,可以用到索引
      

  4.   

    你的时分秒是因为你写入的是time,而你想凭时间查询,最好的方法就是用select * from table where date between '2001-01-01' and '2001-01-02' 
    这样最有效率。
      

  5.   

    select xmlContent from pus where status = 9999999 and convert(varchar(10),receivedTime,120) = '2001-01-01' 我这样写不可以么?
    怎么查不到结果呢?
    我还想问一下,哪个120是什么意思?
      

  6.   

    刚才哪个方法是因为数据库里的数据用2001-1-1写的,哪个VARCHAR(10)就不行了,呵呵,不过谢谢大家!我搞定了。现在付帐
      

  7.   

    用好convert就好了:
    convert(char(10),列名,120)
      

  8.   

    to  blow_jj(纪俊)
    between '2001-01-01' and '2001-01-02'
    等于 date >= '2001-01-01' and date<='2001-01-02' 
    把等于'2001-01-02' 的记录也找出来了,不对。