add

About Me

My photo
Oracle Apps - Techno Functional consultant

Monday, February 25

Birth date query




SELECT
     TRUNC(MONTHS_BETWEEN(LEAST(NVL(:P_TO_DATE,SYSDATE),SYSDATE), NVL(:START_DATE,:START_DATE))/12) "YEARS"
    ,TRUNC(MONTHS_BETWEEN(LEAST(NVL(:P_TO_DATE,SYSDATE),SYSDATE), NVL(:START_DATE,:START_DATE))) - TRUNC(MONTHS_BETWEEN(LEAST(NVL(:P_TO_DATE,SYSDATE),SYSDATE), NVL(:START_DATE,:START_DATE))/12)*12 "MONTHS"        
    ,TRUNC((MONTHS_BETWEEN (LEAST(NVL(:P_TO_DATE,SYSDATE),SYSDATE),NVL(:START_DATE,:START_DATE)) - TRUNC(MONTHS_BETWEEN(LEAST(NVL(:P_TO_DATE,SYSDATE),SYSDATE), NVL(:START_DATE,:START_DATE)))) * 30 ) "DAYS"
from dual


No comments: