因为LIKE 是针对字符型字段的,而你查的却是日期型,当然不行了。日期型字段 可以用‘’括起来表示。所以下面是可以的。

解决方案 »

  1.   

    select * from comment where comdate like '%‘2005-10-11 17:08:00’%'
    是这样括吗?
      

  2.   

    select * from comment where convert(varchar,comdate,120) like '%2005-10-11 17:08:00%'
      

  3.   

    declare @t table
    (t1 datetime)insert @t
    select '2005-10-11 17:08:00' select * from @t where convert(varchar,t1,120) like '%2005-10-11 17:08:00%'t1                                                     
    ------------------------------------------------------ 
    2005-10-11 17:08:00.000(所影响的行数为 1 行)
      

  4.   

    select * from comment where convert(varchar(50),comdate,121) like '%2005-10-11 17:08:00%'
      

  5.   

    select * from comment where convert(char(10),comdate ,121) like '%2005-10-11%'到秒的還不知道