I'm currently working on a project that behaves differently depending on whether it is a public holiday or not (amongst other constraints, obviously). To this end, I'm trying to create a table that contains the date and what day of the week it is (considering 'holiday' to be an eighth 'day of the week').
I have a table I'm sourcing the list of holidays from, named holiday, which has only one field, holidaydate (DATE datatype). The table I'm trying to put the values into is named daydates, with two fields, day (DATE datatype) and dayofweek (CHAR(10) datatype).
This is the logic as I have it at the moment, while I'm testing.
INSERT INTO holiday
(holidaydate)
SELECT sysdate FROM dual;
SELECT sysdate,
(
CASE
WHEN sysdate IN
(SELECT h.holidaydate FROM holiday h)
THEN 'holiday'
ELSE TO_CHAR(sysdate , 'day')
END)
FROM dual;
Unfortunately, it currently returns, say, 'Wednesday', rather than 'holiday'. I have a feeling I need to change the WHEN sysdate IN to a WHEN to_char (sysdate, 'dd-mon-yyyy') IN or something along those lines, but I've tried a few variations and they don't seem to have worked thus far.
Any suggestions?