这样写:
select weathertime,weather from weathers
where to_char(weathertime,'yyyy-mm-dd') = to_char(sysdate,'yyyy-mm-dd');
select weathertime,weather from weathers
where to_char(weathertime,'yyyy-mm-dd') = to_char(sysdate,'yyyy-mm-dd');
2 from weathers
3 where weathertime = to_char(sysdate,'dd-mon-yyyy');
而你資料庫内看者是只有日期,他的的時間其實就是00:00:00
所以你直接那sysdate和一個日期比較的時候要對sysdate取整,而不用進行轉換。試試這個語句.
select weathertime,weather
2 from weathers
3 where weathertime = trunc(sysdate)
你的weathertime是不是日期型?如果不是日期型會報錯。