No Table Required
In Oracle, you do not need to create a temporary table. You can use CONNECT BY LEVEL
to generate the date range. For example:
SELECT
to_char( LEVEL + to_date( '01 DEC', 'DD MON' ) - 1, 'DD MON' ) as created_date
FROM
dual
CONNECT BY LEVEL <= 31
Examples
List of days between two arbitrary dates, to a maximum of 31 days.
SELECT
to_date( &start_date, 'DD-MM-YYYY' ) + LEVEL - 1 match_date
FROM
DUAL
CONNECT BY LEVEL <= (to_date( &end_date,'DD-MM-YYYY' ) - to_date( &start_date,'DD-MM-YYYY' ) + 1) AND LEVEL <= 31
List of months between two arbitrary dates, to a maximum of 12 months.
SELECT
to_char( add_months( to_date( &start_date, 'DD-MM-YYYY' ), LEVEL - 1 ), 'MM-YYYY' ) match_date
FROM
DUAL
CONNECT BY LEVEL <= months_between( to_date( &end_date, 'DD-MM-YYYY' ), to_date( &start_date, 'DD-MM-YYYY' ) ) + 1 AND LEVEL <= 12
List of years between two arbitrary dates, to a maximum of 10 years.
SELECT
to_char( add_months( to_date( &start_date, 'DD-MM-YYYY' ), (LEVEL - 1) * 12 ), 'YYYY' ) match_date
FROM
DUAL
CONNECT BY LEVEL <= months_between( to_date( &end_date, 'DD-MM-YYYY' ), to_date( &start_date, 'DD-MM-YYYY' ) ) / 12 + 1 AND LEVEL <= 10