oracle数据查询时间

现在我要查:
select * from dual where time = to_date('2012-06-18 11:41:41','yyyy-MM-dd hh24:mi:ss');
这样是能查询处理的。
但是,时间是我从页面得到的值,是省略了时分秒的
select * from dual where time = to_date('2012-06-18','yyyy-MM-dd');
这样是查不出来的。

写法有很多种,例如下面的:
方法一:select * from dual where time between to_date('2012-06-18 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2012-06-18 23:59:59','yyyy-mm-dd hh24:mi:ss');
方法二:select * from dual where to_char(time,'yyyy-mm-dd')='2012-06-18';
方法三:select * from dual where trunc(time)=to_date('2012-06-18','yyyy-mm-dd');
当然楼主也可以按上面的先转换下日期的显示格式再查询撒,都可以的,呵呵!!!
原文地址:https://www.cnblogs.com/xuwj/p/3201021.html