to_date()使用
select * from table t where t.time >= to_date(aaaa,'yyyy-mm-dd hh24:mm:ss') and t.time<to_date(bbbb,'yyyy-mm-dd hh24:mm:ss')
aaaa,bbbb是字符串类型 比如:aaaa = '2018-04-19 00:00:00' bbbb = '2018-04-20 00:00:00'
to_date()中yyyy-mm-dd hh24:mm:ss 意思把aaaa字符串转换成 yyyy-mm-dd hh24:mm:ss这样的时间格式
select * from v$session where logon_time>=to_date('2018-04-19 00:00:00','yyyy-mm-dd hh24:mi:ss') and logon_time<to_date('2018-04-20 00:00:00','yyyy-mm-dd hh24:mi:ss');
trunc(sysdate)使用
select * from table t where t.time >= trunc(sysdate) and t.time < trunc(sysdate+1)
sysdate是oracle数据库的系统当前时间 sysdate是时间格式的 trunc是oracle的截取函数 trunc(sysdate) 截取的结果是当前时间的yyyy-mm-dd 截取后也是如期类型
select * from v$session where logon_time>=trunc(sysdate) and logon_time<t