Dates between [message #255827] |
Thu, 02 August 2007 00:27 |
rahulraj25
Messages: 1 Registered: August 2007
|
Junior Member |
|
|
Hi,
I have a table with fields :
Sl_no number(5)
FROM_date date;
TO_date date;
Now i want to display all the months between "From_date" and "To_date", in the frmat 'YYYY month'
for serial number(Sl_no) freater than 10;
eg:
Let From_date 2007 july
and To_date 2007 december
Then the query should produce output as
2007 july
2007 august
2007 september
.......upto 2007 December.
Please help.
|
|
|
|
Re: Dates between [message #255832 is a reply to message #255827] |
Thu, 02 August 2007 00:41 |
|
Michel Cadot
Messages: 68722 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> def from_date=to_date('27/03/2007','DD/MM/YYYY')
SQL> def to_date=to_date('05/08/2007','DD/MM/YYYY')
SQL> select to_char(add_months(&from_date,level-1),'YYYY month') mydate
2 from dual
3 connect by level <= ceil(months_between(&to_date,&from_date))+1
4 order by level
5 /
MYDATE
--------------
2007 march
2007 april
2007 may
2007 june
2007 july
2007 august
6 rows selected.
Regards
Michel
|
|
|