Home » SQL & PL/SQL » SQL & PL/SQL » Dates between
Dates between [message #255827] Thu, 02 August 2007 00:27 Go to next message
Messages: 1
Registered: August 2007
Junior Member

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;


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 #255829 is a reply to message #255827] Thu, 02 August 2007 00:32 Go to previous messageGo to next message
Messages: 24958
Registered: January 2009
Location: SoCal
Senior Member
I'm not clear on what you want & what you tried.
Please try again on both.

Please read & FOLLOW the posting guidelines in the STICKY posts at top of forum.

[Updated on: Thu, 02 August 2007 00:33] by Moderator

Report message to a moderator

Re: Dates between [message #255832 is a reply to message #255827] Thu, 02 August 2007 00:41 Go to previous message
Michel Cadot
Messages: 63911
Registered: March 2007
Location: Nanterre, France, http://...
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  /
2007 march
2007 april
2007 may
2007 june
2007 july
2007 august

6 rows selected.

Previous Topic: index on partition keys useful?
Next Topic: ORA-00932: inconsistent datatypes: expected - got CURSER
Goto Forum:

Current Time: Sat Oct 22 06:58:40 CDT 2016

Total time taken to generate the page: 0.12572 seconds