Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL to generate date intervals of 6 months each between two date ranges

TekuJul 14 2010 — edited Jul 14 2010
Hi All,

I looked in the forums if some one used CREATE_CHUNKS_BY_SQL for dates, but no luck.
I am actually looking to update a table by using chunks of dates.
For which I need to generate date ranges to split them by chunks.

I have a table where I know max(sales_date) and min(sales_date).
Lets say max(sales_date) : 1/1/2008 min(sales_date) : 10/31/2010

I want to split them into 6 month(180 days) intervals as below :
chunk_id	start_date	end_date
--------	----------	--------
  1		01/01/2008	06/30/2008
  2		01/07/2008	12/31/2008
  3		01/01/2009	06/30/2009
  4		01/07/2009	12/31/2009
  5		01/01/2010	06/30/2010
  6		01/07/2010	10/31/2010
It does not have to end exactly by month end. Basically I need those date ranges to be apart 180 days.

I appreciate if someone can throw some ideas on this.

Thanks,
Raj.
This post has been answered by Frank Kulash on Jul 14 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2010
Added on Jul 14 2010
3 comments
2,177 views