Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get a select of 12 month starting with current month down

Status
Not open for further replies.

borisch

Programmer
Jun 4, 2002
11
US
How can I get a select of 12 month starting with current month down. Example 06/2002, 05/2002,..........08/2001,07/2001
Please help
Thanks for your help
 
Not exactly your answer...but seems to be similar...

We run a canned report for a "rolling" last 7 days using trunc(sysdate)-7 as the earliest date and trunc(sysdate) as the latest date.

Sysdate is the system date selected from the "default" dual table that comes with Oracle.
Trunc() gives us a flat date so the date is inclusive of all hours/minutes within that day.
-7 goes 7 days back from the sysdate.


 
SELECT To_Char(Add_Months(SYSDATE,-ROWNUM + 1),'MM/YYYY')
FROM a_table
WHERE ROWNUM <= 12

a_table should be a table, such as DICT, that you can be sure has more than 12 rows in it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top