Re: Is it possible to generate a range of dates by using plain SQL?

From: Eric Lyders-Gustafson <ericlg_at_homemail.com>
Date: Wed, 24 Jun 1998 15:23:05 -0500
Message-ID: <35916029.643FA09F_at_homemail.com>


One way I've gotten date ranges is to use an existing table that has plenty of rows (enough rows for your date range). Like this:

select to_date('05-JUN-98')+rownum-1
from my_table
where to_date('05-JUN-98')+rownum-1 between to_date('05-JUN-98') and to_date('09-JUN-98');

or, another way is:

select to_date('05-JUN-98')+rownum-1
from my_table
where rownum < 6;

Hope this helps.

-Eric

Jack Martens wrote:

> Is it possible to generate a range of dates by using plain SQL?
>
> Example of the result of the query:
>
> DATE
> ---------
> 03-JUN-98
> 04-JUN-98
> 05-JUN-98
> 06-JUN-98
> 07-JUN-98
> 08-JUN-98
> 09-JUN-98
> 10-JUN-98
> 11-JUN-98
>
> I must be able to select a date from the resulting rows, like this:
>
> SELECT date
> FROM date_table
> where date between '05-JUN-98' and '09-JUN-98'
>
> If it is not possible by using plain SQL, what other things could I try
> (e.g. stored procedures)?
>
> Thanks.
Received on Wed Jun 24 1998 - 22:23:05 CEST

Original text of this message