Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL to exclude weekends and bank holidays

User581223Apr 7 2016 — edited Apr 11 2016

Hi, I have following SQL where I want to see CLEARING_DATE for each record for previous month and if the CLEARING_FLAG is not N then I need to add 2 days and see if the second days is not following weekends and bank holidays and produce the next working day to WHERE clause and SELECT statement.I have a static table which stores bank holidays in it example called HOLIDAYS_LIST.

SELECT BANK_ID, ACCOUNT_ID, CLEARING_DATE, CLEARING_COUNTRY_FLAG

FROM ACCOUNT

WHERE TO_CHAR(CASE WHEN CLEARING_COUNRTY_FLAG IS 'N' THEN CLEARING_DATE ELSE CLEARING_DATE+2) END,'MMYYYY') = TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE)-1),'MMYYYY')

Can you please help how can I use the logic in above SQL without any procedure or function etc. only with the SQL. Could be very helpful if you could send the query.

Many thanks

This post has been answered by Dairy Land on Apr 8 2016
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 9 2016
Added on Apr 7 2016
22 comments
13,995 views