Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Saturday, April 5, 2014

Query to get the Number of Years, Months and Days between two Given Dates

SELECT
          TRUNC(MONTHS_BETWEEN  (LEAST(NVL(:P_TO_DATE,SYSDATE),SYSDATE), NVL(:START_DATE,:START_DATE))/12)  Y
         
         ,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 M
        
         ,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 )  D


from dual

No comments:

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect