数据库版本:oracle11g
--获取本周一的日期 select trunc(sysdate, 'd') + 1 as week from dual; --获取本周天的日期 select trunc(sysdate, 'd') + 7 as week from dual; --获取本月第一天的日期 select trunc(sysdate, 'mm') as month from dual; --获取本月最后一天的日期 select last_day(trunc(sysdate)) as month from dual; --获取本季度第一天的日期 select trunc(sysdate, 'Q') as quarter from dual; --获取本季度最后一天的日期 select add_months(trunc(sysdate, 'Q'), 3) - 1 as quarter from dual; --获取本年第一天的日期 select trunc(sysdate, 'yyyy') as year from dual; --获取本年最后一天的日期 select add_months(trunc(sysdate, 'yyyy'), 12) - 1 as year from dual; -- 获取上月的开始时间和结束时间 select to_char(to_date(to_char(add_months(sysdate, -1), 'yyyy-mm'),'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss') as start_month_time from dual; select to_char(to_date(to_char(sysdate, 'yyyy-mm'), 'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss') as end_month_time from dual; -- 获取前一天的开始时间和结束时间 select to_char(to_date(to_char(sysdate - 1, 'yyyy-mm-dd'), 'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss') as start_day_time from dual; select to_char(to_date(to_char(sysdate, 'yyyy-mm-dd'), 'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss') as end_day_time from dual; -- 获取上一个小时的开始时间和结束时间 select to_date(to_char(sysdate, 'yyyy-mm-dd') || (to_char(sysdate, 'hh24') - 1),'yyyy-mm-dd hh24') as start_hour_time from dual; select to_date(to_char(sysdate, 'yyyy-mm-dd') || (to_char(sysdate, 'hh24')),'yyyy-mm-dd hh24') as end_hour_time from dual; -->>其他时间都可以根据这个推导出来···