List the next 30 days dates

ijswalker

Registered User.
Local time
Today, 10:55
Joined
Jun 16, 2008
Messages
67
I am using a passthrough query that queries an Oracle Database and I want to be able to have a list of the next 30 days dates. Does anyone know how to do this. I have an SQL query for listing the same day for the next few months but am struggling to get it to days. See below.

Code:
SELECT TO_CHAR (
  NEXT_DAY (
    LAST_DAY (
        ADD_MONTHS (TRUNC(SYSDATE,'Y'),ROWNUM-1))-7,
        TO_CHAR (TO_DATE('29-01-1927', 'DD-MM-YYYY'),'DAY')
  ), 'DD.MM.YYYY') "Last Saturdays in 2004"
 FROM ALL_OBJECTS
WHERE ROWNUM <= 12;



Can anyone help?

Thanks

Ian
 
After further research the answer is below. This will work in a passthrough query, querying an Oracle database.

Very useful.

Cheers

Ian

Code:
SELECT 
TO_DATE('2010-01-01','YYYY-MM-DD') + ((LEVEL - 1) * 1) start_dt
, LEAST(TO_DATE('2010-01-01','YYYY-MM-DD') + ((LEVEL - 1) * 1) + 9
, TO_DATE('2010-02-20','YYYY-MM-DD')) end_dt  
FROM DUAL  
CONNECT BY TO_DATE('2010-01-01','YYYY-MM-DD') + ((LEVEL - 1) * 1)  <= TO_DATE('2010-02-20','YYYY-MM-DD')
 

Users who are viewing this thread

Back
Top Bottom