查询 AAA里,非空非null,日期为2003-07-01之后的数据。(包括2003-07-01,2004-01-05也算)
字段里 可能有些为非标准的日期数据 如 2003-7-1

解决方案 »

  1.   

    select * from aaa where datediff(d,'2003-07-01',getdate())>0
      

  2.   

    select * from tb 
    where isnull(字段,'')<>'' and 字段<dateadd(dd,1,'2003-07-01')
      

  3.   

    select * 
    from aaa 
    where datediff(d,'2003-07-01',getdate())>= 0
      

  4.   

    select * 
    from aaa 
    where datediff(d,'2003-07-01',getdate())>= 0
      

  5.   

    declare @tb table (dt datetime)
    insert into @tb select null
    insert into @tb select ''
    insert into @tb select '2003-07-01'
    insert into @tb select '2004-01-05'select * from @tb 
    where  dt>='2003-07-01'2003-07-01 00:00:00.000
    2004-01-05 00:00:00.000直接写就行,上面以为小于了
      

  6.   

    服务器: 消息 241,级别 16,状态 1,行 1
    从字符串转换为 datetime 时发生语法错误。
      

  7.   

    select * 
    from aaa 
    where datediff(d,col,getdate())>= 0 and isdate(col)=1
      

  8.   

    SELECT * 
    FROM  AAA
    WHERE 字段名 is not null 
    and convert(varchar(10),日期,120)
      

  9.   

    SELECT *  
    FROM  AAA 
    WHERE 字段名 is not null  
    and convert(varchar(10),日期,120) >='2003-07-01'
      

  10.   

    不知这些可是楼主要的结果。
    我的分析是不是楼主AAA字段里有些不是日期型的数据,想要把他转换为日期型?
    如是这样可以用CAST(AAA AS DATETIME)转换.
      

  11.   

    星辰技术社区:www.netcsharp.cn,我们将帮您以最快的速度找到最佳的解决方案