Accept the sysdate in the following format(YYYYMMDD)and from this date you need to go back 24 months and print all the 24 months dates in ascending order.

Showing Answers 1 - 5 of 5 Answers

OracleTooner

  • Sep 21st, 2007
 

select to_char (add_months (to_date (to_char (sysdate, 'YYYYMMDD'),
'YYYYMMDD'), -R), 'DD-Mon-YYYY') DT
from (select R
from (select rownum R
from ALL_OBJECTS
where rownum <= 24)
order by R desc)

TheSeeker

  • Oct 14th, 2010
 

SELECT   TO_CHAR (ADD_MONTHS (TO_DATE (&1, 'YYYYMMDD'), -ROWNUM),
                  'YYYYMMDD'
                 ) RESULT
    FROM user_tables
   WHERE ROWNUM < 25
ORDER BY 1;


&1 will accept the sysdate in the YYYYMMDD format or if it is always going to be sysdate, then you can do this...

SELECT   TO_CHAR (ADD_MONTHS (TO_DATE (SYSDATE, 'YYYYMMDD'), -ROWNUM),
                  'YYYYMMDD'
                 ) RESULT
    FROM user_tables
   WHERE ROWNUM < 25
ORDER BY 1;

  Was this answer useful?  Yes

Diptiman Badajena

  • Mar 29th, 2012
 

Try this one:

Code
  1.  

  Was this answer useful?  Yes

DURGAPRASAD

  • Jul 24th, 2012
 

Code
  1.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions