Hello,
I need to create a table with the following structure:
calendar week; week start date; week end date
which contains all weeks beginning in 2007 until the current week.
The special thing is, that when an end of month falls within a week, the week is cut in two slices - one record that has a start date that is the beginning of the week and the end date is the last day of the month, and one record that contains the dates of the rest of the week (start date is first of the new month, end date is last day of the week).
Example (beginning of week is monday):
calendar week; week start date; week end date;
...
2009 cW48; 23.11.2009; 29.11.2009
--"normal" week with 7 days, beginning monday and ending sunday
2009 cW49; 30.11.2009; 30.11.2009
--first part of the CW49, which ends at last day of the month
2009 cW49; 01.12.2009; 06.12.2009
--second part of the CW49, which begins at fist day of the new month
2009 cW50; 07.12.2009; 13.12.2009
--"normal" week, without a monthly break
...
How to create such a table in Oracle (SQL or PL SQL)?
Thank you,
Regards
Nadine