Translate

Tuesday, October 12, 2021

Oracle SQL Query to list Months and Years

 


/**************************************************************************

 *PURPOSE: To list out Months and Years                                   *

 *PARAMETERS: LEVEL count                                                 *

 *                                                                        *

 **************************************************************************/

 

 

SELECT a.months

  ||'/'

  ||b.years credit_card_expiration_date

FROM

  (SELECT TO_CHAR(add_months(TRUNC(SYSDATE, 'YYYY'), LEVEL - 1), 'MM') months

  FROM dual

    CONNECT BY LEVEL <= 12

  ) a,

  (SELECT SUBSTR(EXTRACT(YEAR FROM SYSDATE) + (LEVEL-1),3) years

  FROM dual

    CONNECT BY LEVEL <=10

  ) b

WHERE to_date(a.months

  ||'/'

  ||b.years,'mm/yy')>=SYSDATE

ORDER BY b.years,

  a.months;

No comments:

Post a Comment

Text Message

Outside Processing Setups and Cycle in Oracle EBS R12

  OSP Cycle This post is about Oracle Outside Processing Cycle. Outside processing is used when we don't have in house resources to comp...