oracle 存储过程 日期 变量 的相关操作

时间:2022-03-17 14:06:57
V_DATE DATE;
SELECT TRUNC(SYSDATE,'MM') INTO V_DATE FROM DUAL;
SELECT LAST_DAY(SYSDATE) INTO V_DATE FROM DUAL;

SELECT TRUNC(ADD_MONTHS(SYSDATE,-1),'MM') INTO V_DATE FROM DUAL;
SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-1)) INTO V_DATE FROM DUAL;

SELECT TRUNC(ADD_MONTHS(SYSDATE,-11),'MM') INTO V_DATE FROM DUAL;
SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-11)) INTO V_DATE FROM DUAL;

SELECT TRUNC(ADD_MONTHS(SYSDATE,-12),'MM') INTO V_DATE FROM DUAL;
SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-12)) INTO V_DATE FROM DUAL;