cancel
Showing results for 
Search instead for 
Did you mean: 

Date calculation excluding weekends

Former Member
0 Kudos

Hi Friends,

Can please let me know, how to exclude the weekends from date value. Please find the my logic below.

If Header.Flag = 'Y' and Header.CheckInDate is blank,then 12/31/2020

If Header.Flag = 'Y' and Header.CheckInDate is not blank, then Header.CheckInDate - 3 working days (exclude weekends)

If Header.Flag <>'Y'then Current Date + 21 business days

Thanks & Regards,

Balamurugan G

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bala,

I hope this would help you.

For case 2:

If Header.Flag = 'Y' and Header.CheckInDate is not blank, then Header.CheckInDate - 3 working days (exclude weekends)

Solution:-decode(day_in_week(Header.CheckInDate)<=3,Header.CheckInDate-5,Header.CheckInDate-3)


For Case 3:

If Header.Flag <>'Y'then Current Date + 21 business days

Solution:-decode(day_in_week(Current Date+21+8)=6,Current Date+31,day_in_week(Current Date+21+8)=7,Current Date+30,Current Date+29)


Regards,

Sandeep

Former Member
0 Kudos

Hi Sandeep,

Thanks a lot for your help. Your solution is helped me to find the working days excluding weekends. I made small correction in your code and it works perfectly.

Please find the correct code below:

For case 2:

decode(day_in_week(Q_Join.CheckInDate)<=3, Q_Join.CheckInDate-5,

day_in_week(Q_Join.CheckInDate)=7, Q_Join.CheckInDate-4,

Q_Join.CheckInDate-3)

For case 3:

decode(day_in_week(Q_Join.SysDate)=5, Q_Join.SysDate+31,

day_in_week(Q_Join.SysDate)=6, Q_Join.SysDate+30,

Q_Join.SysDate+29)

Thanks & Regards,

Balamurugan G

Answers (0)