DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Query return data between two fixed points in time.

Threaded View

  1. #1
    Join Date
    Mar 2004
    Posts
    55

    Query return data between two fixed points in time.

    I have a table with a datestamp column which indicates wheren the record was written to the database table.

    I am trying to write a query that will return all records that are in a date range between 6am (today) and 6am (a week ago).

    I understand how to do the date range part however unsure how to enforce the 6am condition.

    The query needs to be able to be run without changing the query on a regular basis. I should be able to run the query at any time during the day and it should stick to return only records between 6am 7 days ago and 6am today.

    i have written thusfar

    SELECT xxxx.table
    FROM table
    WHERE to_date(reportdate,'DD/MM/YYYY')
    BETWEEN to_date(sysdate-7,'DD/MM/YYYY')
    AND to_date(reportdate,'DD/MM/YYYY')

    Thankyou
    Last edited by mozart; 11-15-2006 at 05:18 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width