첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
SET SERVEROUTPUT ON;

DECLARE
    V_DATE DATE;
    
    FUNCTION AddMonth(P_SOURCE_DATE IN DATE, P_MONTH_COUNT IN NUMBER) RETURN DATE
    IS
        V_SOURCE_DAY   NUMBER;
        V_TARGET_DATE   DATE;
        V_TARGET_DAY  NUMBER;
    BEGIN
        V_SOURCE_DAY := TO_NUMBER(TO_CHAR(P_SOURCE_DATE, 'DD'));

        V_TARGET_DATE := ADD_MONTHS(P_SOURCE_DATE, P_MONTH_COUNT);

        V_TARGET_DAY := TO_NUMBER(TO_CHAR(V_TARGET_DATE, 'DD'));
    
        IF V_TARGET_DAY > V_SOURCE_DAY
        THEN
            V_TARGET_DATE := V_TARGET_DATE - (V_TARGET_DAY - V_SOURCE_DAY);
        END IF;
    
        RETURN V_TARGET_DATE;
    END;
BEGIN
    V_DATE := AddMonth(TO_DATE('2019-02-28', 'yyyy-mm-dd'), 1);
    
    DBMS_OUTPUT.PUT_LINE(V_DATE);
END;
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요