这样写:
select weathertime,weather from weathers 
where to_char(weathertime,'yyyy-mm-dd') = to_char(sysdate,'yyyy-mm-dd');

解决方案 »

  1.   

    SQL> select weathertime,weather 
      2  from weathers 
      3  where weathertime = to_char(sysdate,'dd-mon-yyyy');
      

  2.   

    楼上说的确实可行,久闻oracle里面的日期型数据特别难缠,很多程序员都一律把日期类型转换成字符型来处理。虽然问题解决了,但我还是想问问,这是什么道理呢?为什么我上面的sql语句就不能执行?
      

  3.   

    是你理解錯誤,orcle裏的date型是默認包含時間的sysdate是包含時間的函數,返回值是當前日期+當前時間
    而你資料庫内看者是只有日期,他的的時間其實就是00:00:00
    所以你直接那sysdate和一個日期比較的時候要對sysdate取整,而不用進行轉換。試試這個語句.
    select weathertime,weather 
      2  from weathers 
      3  where weathertime = trunc(sysdate)
    你的weathertime是不是日期型?如果不是日期型會報錯。