Home » SQL & PL/SQL » SQL & PL/SQL » list dates from <some date> to sysdate (Oracle 10g)
list dates from <some date> to sysdate [message #319266] Fri, 09 May 2008 09:23 Go to next message
beetel
Messages: 96
Registered: April 2007
Member
Hi,

I would like to list the dates from a cut-off date to current date. For instance, the cut-off-date is 2008-05-01 (format is YYYY-MM-DD) and the sysdate is 2008-05-07. I would like a query that would give me:

2008-05-02
2008-05-03
2008-05-04
2008-05-05
2008-05-06
2008-05-07

Thanks in advance..
Re: list dates from <some date> to sysdate [message #319269 is a reply to message #319266] Fri, 09 May 2008 09:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Search for "calendar" and/or "row generator".

Regards
Michel
Re: list dates from <some date> to sysdate [message #319327 is a reply to message #319269] Fri, 09 May 2008 17:37 Go to previous messageGo to next message
Kprattip
Messages: 15
Registered: January 2006
Location: INDIA
Junior Member
Hi Beetel,

You can use the following Query,

SELECT TO_DATE('10-JUN-2007', 'DD-MON-YYYY')+ rownum
FROM (SELECT 1 from DUAL CONNECT BY level <= ( SYSDATE - to_date('10-JUN-2007', 'DD-MON-YYYY'));

This prints all dates from 10-JUN-2007.

Cheers,
Kiran.

Re: list dates from <some date> to sysdate [message #319351 is a reply to message #319327] Sat, 10 May 2008 00:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Kprattip,

please read OraFAQ Forum Guide.

1/ "How to format your post?" section
How to use code tags
Indent the code (See SQL Formatter)
Make sure that lines of code do not exceed 80 characters
Use the "Preview Message" button to verify.

2/ "Responding to Posts" section
Don't put solution only hint or clue.
Quote:
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.


Regards
Michel

[Updated on: Sat, 10 May 2008 00:44]

Report message to a moderator

Re: list dates from <some date> to sysdate [message #319531 is a reply to message #319351] Mon, 12 May 2008 02:05 Go to previous messageGo to next message
rahul15june
Messages: 35
Registered: May 2008
Member
Michel,

I am not sure if you own ORafaq, But I really did not understand this quote of yours?

"
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.

"

Any reason why people cannot provide solutions to problem posted even if it is simple? And one has to decide of it is a students issue or a real life problem? I mean we do the reasearh and come online when we are not able to find a solution. Beside " easy " is a relative word. I though Orafaq was a open forum and for the first time I came across someone trying to dicatate what should be posted and what should not. Even though it is realted with oracle.

The user guide says,
Never belittle anyone for asking beginner-level questions or for their English skills.

I hope you dont take it personally. The only reason that comes to my mind, is because you own the forum and you are looking to reduce space. ?

Cheers

Re: list dates from <some date> to sysdate [message #319537 is a reply to message #319531] Mon, 12 May 2008 02:22 Go to previous message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
The quote is from the guide you should have read it before posting.
OraFAQ chooses to help people learn rather than providing direct solution. This is his choice, other forums do what they want.

I don't think my post belittle you or the OP in anyway.

Quote:
I mean we do the reasearh and come online when we are not able to find a solution.

This may be your case but not OP's one, the calendar/row generator question is asked every week, a small search would have give him the solution (by the way I gave him the keywords to search maybe this is belittle him).

Regards
Michel
Previous Topic: error from compiling
Next Topic: Views:advantages
Goto Forum:
  


Current Time: Sat Feb 08 07:56:39 CST 2025