标签:sel char 时间 sele 写在前面 number dual ber href
在使用Oracle数据开发的时候,经常会使用到Oracle的日期的查询。
以下总结有关Oracle日期查询相关。
SELECT TO_CHAR(SYSDATE,'YYYY')||'年' FROM DUAL;
SELECT TO_CHAR(SYSDATE,'MM')||'月' FROM DUAL;
SELECT TO_CHAR(SYSDATE,'DD')||'日' FROM DUAL;
SELECT TO_CHAR(SYSDATE,'Q')||'季' FROM DUAL;
SELECT TO_CHAR(SYSDATE,'IW')||'周' FROM DUAL;
SELECT EXTRACT(YEAR FROM SYSDATE)||'年' FROM DUAL;
SELECT EXTRACT(MONTH FROM SYSDATE)||'月' FROM DUAL;
SELECT EXTRACT(DAY FROM SYSDATE)||'日' FROM DUAL;
SELECT
TO_CHAR(SYSDATE,'yyyymmdd')-TO_NUMBER(TO_CHAR(SYSDATE,'d')-1)-6,
TO_CHAR(SYSDATE,'yyyymmdd')-TO_NUMBER(TO_CHAR(SYSDATE,'d')-1) FROM DUAL;
SELECT TO_CHAR(SYSDATE-INTERVAL '1' MINUTE,'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
SELECT TO_CHAR(SYSDATE-INTERVAL '1' HOUR,'YYYY-MM-DD HH:24:MI:SS') FROM DUAL;
SELECT TO_CHAR(SYSDATE-INTERVAL '1' DAY,'YYYY-MM-DD HH:24:MI:SS') FROM DUAL;
SELECT TO_CHAR(SYSDATE-INTERVAL '1' YEAR,'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
SELECT TO_CHAR(ADD_MONTHS(SYSDATE,0),'YYYY-MM-DD') FROM DUAL;
SELECT TO_CHAR(ADD_MONTHS(SYSDATE,-1),'YYYY-MM-DE') FROM DUAL;
SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD') FROM DUAL;
SELECT TOCHAR(SYSDATE-1,'YYYY-MM-DD') FROM DUAL;
标签:sel char 时间 sele 写在前面 number dual ber href
原文地址:https://www.cnblogs.com/ZengJiaLin/p/11589459.html