Oracle获取月初/月末/季初/季末/半年初/半年末/年初/年末
V_BEGIN_DT_M DATE; --按月开始日期 V_BEGIN_DT_Q DATE; --按季开始日期 V_BEGIN_DT_H DATE; --按半年开始日期 V_BEGIN_DT_Y DATE; --按年开始日期 V_END_DT_M DATE; --按月结束日期 V_END_DT_Q DATE; --按季结束日期 V_END_DT_H DATE; --按半年结束日期 V_END_DT_Y DATE; --按年结束日期 SELECT TRUNC(V_DATE,'MM') V_DATE_M,--月报 TRUNC(V_DATE,'Q') V_DATE_Q, --季报 CASE WHEN TO_CHAR(V_DATE,'MM') <'07' THEN TRUNC(V_DATE,'YYYY') WHEN TO_CHAR(V_DATE,'MM') >'06' THEN PKG_COMM_UTIL.FUNC_TO_DATE((TO_CHAR(V_DATE,'YYYY') || '0701'),'YYYYMMDD') END V_DATE_H, --半年报 TRUNC(V_DATE,'YYYY') V_DATE_Y, --年报 LAST_DAY(V_DATE) AS V_END_DT_M, ADD_MONTHS(TRUNC(V_DATE,'Q'),3)-1 AS V_END_DT_Q, CASE WHEN TO_CHAR(V_DATE, 'MM') < '07' THEN ADD_MONTHS(TRUNC(V_DATE,'YYYY'),6)-1 WHEN TO_CHAR(V_DATE, 'MM') > '06' THEN ADD_MONTHS(TRUNC(V_DATE,'YYYY'),12)-1 END AS V_END_DT_H, ADD_MONTHS(TRUNC(V_DATE,'YYYY'),12)-1 AS V_END_DT_Y INTO V_BEGIN_DT_M, V_BEGIN_DT_Q, V_BEGIN_DT_H, V_BEGIN_DT_Y, V_END_DT_M, V_END_DT_Q, V_END_DT_H, V_END_DT_Y FROM DUAL;
All for u