Home » SQL & PL/SQL » SQL & PL/SQL » List of Months between range (merged 3)
List of Months between range (merged 3) [message #398704] Fri, 17 April 2009 03:48 Go to next message
bernandas
Messages: 16
Registered: June 2007
Location: Chennai
Junior Member
Dear Experts,

i want to list the months between the date range.

Ex:

Date Range :- 01-apr-2008 to 31-mar-2009

my output should look like this

APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
DEC
JAN
FEB
MAR


PL HELP ME IN THIS REGARDS. THANKS IN ADVANCE
Re: List of Months between range (merged 3) [message #398717 is a reply to message #398704] Fri, 17 April 2009 04:17 Go to previous messageGo to next message
danish_fsd@yahoo.com
Messages: 38
Registered: February 2008
Location: Pakistan
Member
Hi,

Hope following will help you.

SELECT DISTINCT to_char(d,'MON') 
FROM
    (
    SELECT TO_DATE('01/01/2003', 'MM/DD/YYYY') - 1 + rownum AS d
    FROM all_objects
    WHERE TO_DATE('01/01/2003', 'MM/DD/YYYY') - 1 + rownum <=
                              TO_DATE('04/05/2003', 'MM/DD/YYYY')
    );


Regards

Danish.
Re: List of Months between range (merged 3) [message #398719 is a reply to message #398704] Fri, 17 April 2009 04:22 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Search for calendar, many solution.

Don't multipost and don't post in UPPER case but read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: LIST OF MONTHS BETWEEN THE RANGE [message #398720 is a reply to message #398704] Fri, 17 April 2009 04:24 Go to previous message
bonker
Messages: 402
Registered: July 2005
Senior Member
Hint

Use Months_between function http://download.oracle.com/docs/cd/B28359_01/olap.111/b28126/dml_functions_2028.htm and row_generator techique http://www.orafaq.com/wiki/Oracle_Row_Generator_Techniquesto achieve this
Previous Topic: UTL_FILE
Next Topic: Passing array having the columns name as its elements
Goto Forum:
  


Current Time: Mon Dec 05 20:59:25 CST 2016

Total time taken to generate the page: 0.09710 seconds