list dates in previous 4 weeks - oracle sql

Posted on 2011-09-29
Last Modified: 2012-05-12
i need to write some code to list all the days within the last 4 weeks of the report run date.

If the report was run today (29-sep-2011) i'd want the output to appear as in fig1.
The report would use the current week as week 4, and the 3 weeks prior to that.

If the report was run on 03-Oct-2011 id want the output to appeart as in fig2.

note that the weeks run from Monday - Sunday.

Further more i then want two time stamps to appear next to each day - the times are 10am and 4pm as displayed in fig3. I need the date/ timestamp to be in a usable format (ie not char) so that i can use the output later on to work out time durations.


Question by:tonMachine100
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 74

Accepted Solution

sdstuber earned 500 total points
ID: 36814042
try this...

SELECT d + h / 24 asm_date, TO_CHAR(d + h / 24, 'Day') day_of_week
          FROM DUAL
        CONNECT BY LEVEL <= 28),
       (SELECT 10 h FROM DUAL
        UNION ALL
        SELECT 16 FROM DUAL)

Author Closing Comment

ID: 36814074
works great - thankyou

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question