查询前一天的数据
select entity_syscode, forwarder, handler, senddate, messagestatus, messageid, messagetype, senderid, receiverid, sendtime, airways_code, airways_name_en, airways_name_cn, aircraft_no, aero_model, aero_type, aero_nationality, cert_no, gross_weight, passenger_limit, use_relation, deliver_date, memo, owner_co, t.entity_xml.getclobval() entity_xml from Tra001_XE t where t.senddate BETWEEN to_date(to_char(sysdate-1,'yyyy-mm-dd ')||'00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date(to_char(sysdate-1,'yyyy-mm-dd ')||'23:59:59','yyyy-mm-dd hh24:mi:ss')
查询一小时
select concat(to_char(sysdate,'yyyy-mm-dd ')||(to_char(sysdate,'hh24')-1),':00:00') start_time,concat(to_char(sysdate,'yyyy-mm-dd hh24'),':00:00') end_time from dual
结果:
查询前一天
select to_char(sysdate-1,'yyyy-mm-dd ')||'00:00:00' start_time,to_char(sysdate-1,'yyyy-mm-dd ')||'23:59:59' end_time from dual
结果:
查询前一个月
select concat(to_char(sysdate,'yyyy')||to_char(add_months(sysdate,-1), '-MM-'),'01 00:00:00')start_time,
concat(to_char(sysdate,'yyyy')||to_char(add_months(sysdate,-1), '-MM-')||to_char(LAST_DAY(sysdate),'dd '),'23:59:59') end_time from dual
结果:
查询前一年
select extract(year from sysdate)-1||'-01-01 00:00:00' start_time,concat(extract(year from sysdate)-1||'-12-'||to_char(LAST_DAY(sysdate),'dd '),'23:59:59') end_time from dual