Is this the best way to determine if an Oracle date is on a weekend?
select * from mytable
where
TO_CHAR (my_date, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN');
Is this the best way to determine if an Oracle date is on a weekend?
select * from mytable
where
TO_CHAR (my_date, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN');
Not an answer to the question. But some more information. There are many more SQL tricks with date.
More here:
to_char
function.is NOT correct! The day number of weekend days may be 6 & 7, or 7 and 1, depending on the NLS-settings.
So the PROPER test (irrespective of NLS-settings) is this one mentioned before:
In my opinion the best option is
TO_CHAR (my_date, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN')
As of Oracle 11g, yes. The only viable region agnostic alternative that I've seen is as follows:
set NLS_TERRITORY before
So you are sure which numbers are weekends