Search code examples
sqloracledateoracle-sqldevelopersysdate

sql oracle sysdate: ignore weekends


I am using this code in my where:

and table.datum >= sysdate-7
and table.datum <= sysdate

It shows data from the last 7 days - I want to add that it ignores weekends (Saturday and Sunday) - I checked the Internet but nothing works for me!


Solution

  • Use Between and add this where statement.

    AND table.datum BETWEEN sysdate-7 and sysdate
    AND TO_CHAR(to_date(substr(table.datum,1,10), 'DD-MM-YYYY'),
                             'D', 'NLS_DATE_LANGUAGE=ENGLISH') NOT IN ('1', '7')