select * from tablename where y_type<'2004-10-4'

解决方案 »

  1.   

    --按天比较select * from 表 where datediff(day,Y_type,'2004-10-4')>0
      

  2.   

    不写程序了,忘了aspsql:select * from tablename where Y_type<'20041004'
      

  3.   

    declare @t table(Y_type datetime)
    insert @t select '2004-10-1'
    union all select '2004-10-2'
    union all select '2004-10-3'
    union all select '2004-10-4'
    union all select '2004-10-5'select * from @t where datediff(day,Y_type,'2004-10-4')>0
    /*--测试结果Y_type                                                 
    ------------------------------------------------------ 
    2004-10-01 00:00:00.000
    2004-10-02 00:00:00.000
    2004-10-03 00:00:00.000(所影响的行数为 3 行)
    --*/
      

  4.   

    还是不行啊!
    我把代码发出来a !
    select Y_type,SUM(Y_RMB) as a from admin_yewu where datediff(day,Y_time,'2001-1-1')>=0 and datediff(day,Y_time,'2004-1-1')<=0 group by Y_type 什么都是对的!就是遇到时间就取不出来了!去掉时间就是对的!
      

  5.   

    看看是否表中数据有问题.select * from admin_yewu where isdate(Y_time)=0
      

  6.   

    你弄反了
    select Y_type,SUM(Y_RMB) as a from admin_yewu where datediff(day,Y_time,'2001-1-1')<=0 and datediff(day,Y_time,'2004-1-1')>=0 group by Y_type 
      

  7.   

    datediff(day,Y_time,'2001-1-1')>=0是比2001-1-1还早
    datediff(day,Y_time,'2004-1-1')<=0是比'2004-1-1还晚
      

  8.   

    ……还是不行啊!sql server的数据库真不好用阿!
      

  9.   

    你用 convert函数转换,因为一个是日期一个是字符当然没有办法啊,
    select * from tb whre convert(char(10),y_type,120)<'2004-10-4'