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
>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);