Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Select dates between two dates
The following may do the trick :
1. Create a table to hold your date list :
create table daterange(datelist date); 2. Create a procedure to populate your date list table :
CREATE OR REPLACE PROCEDURE GetDateRange( p_Date1 IN DATE , p_Date2 IN DATE ) IS v_Date Date; BEGIN Delete from DateRange; v_Date := p_Date1; While v_Date <= p_Date2 LOOP Insert into DateRange values (v_Date); v_Date := v_Date + 1; END LOOP;
3. Execute the procedure with your start and end dates :
exec getdaterange('29-dec-1998','15-jan-1999');
Hope this helps.
Rob Medley
medleyrk_at_iafrica.com
> I would like to create a query (or procedure/function/package ...)
> that returns days between two dates. Eg:
>
> select ...(sysdate, sysdate + 2);
>
> 1998-12-28
> 1998-12-29
> 1998-12-30
>
> Datas must be returned as a table because I need to perfom a
> join with other tables.
>
> (Oracle 8.0.5)
>
> Thanks for any hints.
>
> ---
> Yann Doussot <doussot_at_gifrance.com>
> Grey Interactive - France - http://www.gifrance.com/
> Cell: +33 6 12 71 70 03 Work: + 33 1 46 84 85 00
Received on Mon Dec 28 1998 - 16:21:06 CST