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

Accounts Receivable-AR setups in Oracle EBS Functional Financials - Apps R12

   1. Oracle Receivables -> Setup -> System ->System Options     a. Receivable GL related setup    b. Transaction and Customer rela...