我想查12月31号以后的数据
select * from tb where stime>2007-12-31
这个语句有什么问题啊?怎么查出来连07年5月份的数据都有啊(stime字段的形式是1989-12-30 12:23:13这种格式的,DATETIME型)
高手指点下

解决方案 »

  1.   

    select   *   from   tb   where   stime> '2007-12-31'
      

  2.   

    select * from tb where  convert(datetime ,stime,120)>'2007-12-31'
      

  3.   


    select * from tb where convert(varchar(10),stime,120)>   '2007-12-31'
      

  4.   

    我想查12月31号以后的数据 
    select   *   from   tb   where   stime> 2007-12-31 
    这个语句有什么问题啊?怎么查出来连07年5月份的数据都有啊(stime字段的形式是1989-12-30   12:23:13这种格式的,DATETIME型) 
    高手指点下 select   *   from   tb   where   stime> '2007-12-31'select   *   from   tb   where   convert(varchar(10),stime,120)> '2007-12-31'
      

  5.   

    1 日期型的也需要单引号
    2 取到天数,最好先datetime型的转成varchar()型的。