How to write a query to retrieve only the months from certain given duration.

I will be getting this duration from the dual table. Provide query for this.

Like for example, if suppose I am going to get value from the month of 01-Jan-2006 to 31-Apr-2007 then My result should be only 4 months like Jan, Feb, Mar, Apr.
Btu not the whole dates. Only four rows has to be retrieved. This should be retrieved from the dual table but not from other tables.

Showing Answers 1 - 3 of 3 Answers

jamesravid

  • Jul 18th, 2007
 

Use this query,

select to_char(add_months('01-jan-2007',rownum-1),'MON') from user_objects where add_months('01-jan-2007',rownum-1) < '30-apr-2007';

  Was this answer useful?  Yes

Imran_Javed

  • May 13th, 2008
 

SELECT
  TO_CHAR(ADD_MONTHS('01-jan-2007',
  ROWNUM-1),
  'MON')
FROM
 dual
WHERE
  ADD_MONTHS('01-jan-2007',ROWNUM-1) < '30-apr-2007'
 CONNECT BY LEVEL <=12;

  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