Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Search Last 7 days excluding today Oracle SQL

I have the below code to which I want to return the last 7 days excluding today (for example from 5th May – 11th May as opposed to 5th May – 12th May)

What else would I be able to include to acheive this?

    SELECT * 
FROM TABLE_1
WHERE DATE_TIME >= SYSDATE -7

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You want to have a range that starts from 7 days before midnight today and ends before midnight today:

SELECT *
FROM   table_name
WHERE  date_time >= TRUNC(sysdate) - 7
AND    date_time <  TRUNC(sysdate);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading