Monday, April 1, 2019

Set date to be the next Monday if date is on weekend using workflow

The below formula will return the date if the date inputted is a weekday or the following Monday if it falls on a weekend.  The field {x} should be the id of the date field to be checked or {today} for the current date.

case when INSTR(to_char({x}, 'DAY'),'SATURDAY') != 0 then {x}+2 when INSTR(to_char({x}, 'DAY'),'SUNDAY') != 0 then {x}+1 else {x} end

This can be used in a set field value action as a formula value for the field {x} or it can be used just to check if it date is on the weekend by comparing the return value of the formula with the original value of the field (if the value returned by the case statement is different than the value of the field it means it is on a weekend).

No comments:

Post a Comment