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!

determine if date is a weekend

elmasduroSep 4 2015 — edited Sep 4 2015

hi all, consider the following data:

WITH data AS (

SELECT To_Date('08/21/2015','mm/dd/yyyy') + 1 weekday FROM dual

UNION ALL

SELECT To_Date('08/24/2015','mm/dd/yyyy') + 1  weekday FROM dual

UNION ALL

SELECT To_Date('08/28/2015','mm/dd/yyyy') + 1 weekday FROM dual

UNION ALL

SELECT To_Date('09/2/2015','mm/dd/yyyy') + 1 weekday FROM dual

)

i hardcoded the dates but in the original query it will be dynamically.  what i want to do is to find out if  date + 1 falls on a weekend. if it does, then i want to increase the date to the next available weekday. if it is not a weekend, then leave date + 1 intact.  my output from the data above should be:

weekday

=========

08/24/2015       -- aug 21+ 1  falls on a weekend, so increase the date to next available weekday (8/24)

08/25/2015       --aug24 + 1 falls in a weekday so leave intact

08/31/2015       -- aug28 + 1 falls on a weekend,  so increase the date to next available weekday (8/31)

09/03/2015       --sep02 + 1 falls in a weekday so leave intact

can someone help me write a query that perform the above output? thanks

This post has been answered by Nick Strange on Sep 4 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2015
Added on Sep 4 2015
9 comments
3,320 views