我数据库里面有一个时间字段,类型是datetime
比如说一个数据2008-11-12 14:25:22:444,我想按2008-11-12这种格式查询出来
我写的语句 select* from table where convert(datetime,字段,120)='2008-11-12'查询不出
这事什么问题?

解决方案 »

  1.   

    select convert(varchar(120),字段名,120) as 字段名 from 表名
      

  2.   

    select* from table where convert(nvarchar(10),字段,121)='2008-11-12'
      

  3.   

     select* from table where convert(nvarchar(10),字段,120)='2008-11-12' 
      

  4.   

    code=SQL]select convert(varchar(10),getdate(),120)[[/code]
      

  5.   

    select* from table where convert(varchar(10),字段,120)='2008-11-12'
      

  6.   

    --呵呵看錯了,datetime-->varchar(10)
      

  7.   

    select* from table where Datediff(day,字段,'2008-11-12')=0
      

  8.   


    select* from table where convert(varchar(10),字段,120)='2008-11-12'