top of page

72. Nearest/Next Business Day

Description

How to automatically move a date that falls on a Saturday/Sunday to either the nearest or next business day.

Code

Nearest Weekday/Business Day:

IF DAY OF WEEK( DateVar ) = 1
DateVar + 1 DAYS
ELSE IF DAY OF WEEK( DateVar ) = 7
DateVar - 1 DAYS
ELSE
DateVar
END IF


Next Weekday/Business Day:

IF DAY OF WEEK( DateVar ) = 1
DateVar + 1 DAYS
ELSE IF DAY OF WEEK( DateVar ) = 7
DateVar + 2 DAYS
ELSE
DateVar
END IF

Explanation

This computation checks a date variable to see what day of the week it falls on using the DAY OF WEEK model. If DAY OF WEEK returns a 1 (Sunday) or a 7 (Saturday), then the date is appropriately moved to the next or previous weekday using DATE + NUM DAYS or DATE - NUM DAYS. The computation returns the adjusted date or, if no adjustment was made, the original date.

bottom of page