"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
One way round NLS settings could be
mod(trunc(mydate)-to_date('01-01-1900','DD-MM-YYYY'),7) not in (5,6)
It's a fudge, and won't work for dates before 1900. No doubt someone can dress it up . . . .
pando's code is more transparent and works for all dates. It may also be neat start for other definitions of a weekend (e.g. Muslim Thu & Fri).
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
SELECT ...
FROM data
WHERE TO_CHAR(date_col,'Dy') NOT IN ('Sat','Sun');
Obviously you'll have to change this if NLS isn't English language.
Looking back - very similar to Pando's!
I work with (near??) a VB developer who's created a table in one of our Oracle Databases that stores the date of every weekend for the next 5 years to help him with a similar problem. Refused to use the 'Dy' solution as he'd have to change his code.
war story: I could not find out how to do exponentiation in AS/400 Query - so I created a table of powers of 10
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
Bookmarks