From Evernote: |
ORACLE 开始时间 & 结束时间Clipped from: http://blog.csdn.net/long_ge_cool/article/details/8601157 |
SELECT to_date(to_char(sysdate+1,'yyyy-mm-dd'),'yyyy-mm-dd') from dual 今天结束时间
SELECT to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd') from dual 今天开始时间
获取上一个小时的开始时间和结束时间
select to_date(to_char(sysdate,'yyyy-mm-dd')||(to_char(sysdate,'hh24')-1),'yyyy-mm-dd hh24') from dual;
select to_date(to_char(sysdate,'yyyy-mm-dd')||(to_char(sysdate,'hh24')),'yyyy-mm-dd hh24') from dual;
select to_date(to_char(sysdate,'yyyy-mm-dd')||(to_char(sysdate,'hh24')-1),'yyyy-mm-dd hh24') from dual;
select to_date(to_char(sysdate,'yyyy-mm-dd')||(to_char(sysdate,'hh24')),'yyyy-mm-dd hh24') from dual;
-- 获取上月的开始时间和结束时间
select to_char(to_date(to_char(add_months(sysdate,-1),'yyyy-mm'),'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss') from dual;
select to_char(to_date(to_char(sysdate,'yyyy-mm'),'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss') from dual;
select to_char(to_date(to_char(add_months(sysdate,-1),'yyyy-mm'),'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss') from dual;
select to_char(to_date(to_char(sysdate,'yyyy-mm'),'yyyy-mm'),'yyyy-mm-dd hh24:mi:ss') from dual;
--本周
select trunc(sysdate,'d')+1 from dual;
select trunc(sysdate,'d')+7 from dual;
--本月
select trunc(sysdate,'mm') from dual;
select last_day(trunc(sysdate)) from dual;
--本季
select trunc(sysdate,'Q') from dual;
select add_months(trunc(sysdate,'Q'),3)-1 from dual;
--本年
select trunc(sysdate,'yyyy') from dual;
select add_months(trunc(sysdate,'yyyy'),12)-1 from dual;
select trunc(sysdate,'d')+1 from dual;
select trunc(sysdate,'d')+7 from dual;
--本月
select trunc(sysdate,'mm') from dual;
select last_day(trunc(sysdate)) from dual;
--本季
select trunc(sysdate,'Q') from dual;
select add_months(trunc(sysdate,'Q'),3)-1 from dual;
--本年
select trunc(sysdate,'yyyy') from dual;
select add_months(trunc(sysdate,'yyyy'),12)-1 from dual;
没有评论:
发表评论