数据库中有这样的2009-8-12 13:17:50 数据记录现在select * from table1 where date>'2009-8-12 13:17:50'
和select * from table where date>#2009-8-12 13:17:50#都通不过盼高人指点一二

解决方案 »

  1.   

    select * from table1 
    where datediff(mm,'2009-8-12 13:17:50', date)>0
      

  2.   

    select * from table1 
    where datediff(ms,'2009-8-12 13:17:50', date)>0
      

  3.   

    select 
       * 
    from 
       table1 
    where 
       datediff(mm,'2009-8-12 13:17:50', date)>0DATEDIFF
    返回跨两个指定日期的日期和时间边界数。 语法
    DATEDIFF ( datepart , startdate , enddate 
      

  4.   

    除了用datediff还有其他方法吗?
      

  5.   

    --TRY
    select * from table1 where cast(date as datetime)>'2009-8-12 13:17:50'
      

  6.   

    select * from table1 where CONVERT(DATETIME,date)>'2009-8-12 13:17:50' 
      

  7.   

    datediff or dateadd 搞定
      

  8.   

    select * from table1 where date>'2009-8-12 13:17:50' 
    如果date是datetime的话,应该可以直接比较的。
      

  9.   

    DATEDIFF
    CAST
    CONVERT
    还可以用YEAR(),MONTH(),DAY(),或者DATEPART()分别取各个部分进行判断
      

  10.   

    oracle:
    select * from table1 where date>to_date('2009-8-12 13:17:50','yyyy-mm-dd') 
    db2:
    select * from table1 where date>date('2009-8-12 13:17:50','yyyy-mm-dd')