954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dates between the two given dates

Hi,

Can we get a SQL query, to display all the dates between two given dates
eg. if date1=21-mar-2007 and date2=25-mar-2007
then the query should display all the dates between those two given dates i.e
22-mar-2007, 22-mar-2007, 23-mar-2007and 24-mar-2007.

Query should not contain any plsql coding.

Regards.

pointers
Light Poster
34 posts since Oct 2006
Reputation Points: 12
Solved Threads: 1
 

You need to use BETWEEN clause .

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

You could try something like

select date1 + rownum
    from all_objects
    where rownum < date2 - date1;


Nige

Nige Ridd
Junior Poster in Training
52 posts since Nov 2007
Reputation Points: 13
Solved Threads: 9
 

I tried but dint get.....if u can pls help me out...

pointers
Light Poster
34 posts since Oct 2006
Reputation Points: 12
Solved Threads: 1
 

How are you trying to run it? If you are using strings for the values of date1 & date2 then you'll have to put to_date() round each one as it uses the date arithmetic features in Oracle.
Nige

Nige Ridd
Junior Poster in Training
52 posts since Nov 2007
Reputation Points: 13
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You