
DAY OF WEEK Function
The DAY OF WEEK function converts a Date variable's answer to a number between 0 and 6 representing the day of the week the date falls on.
You use this function to automate date adjustments for business logic, for example avoiding weekends; combine this function with conditional logic (IF, ELSE) to create dynamic templates.
Function name | DAY OF WEEK |
Usage model | DAY OF WEEK ( d:DATE ) |
Parameters | This function requires you to replace only one parameter: |
d: DATE | The function determines the day of the week that this date falls on. |
Result | A number value between 0 and 6, corresponding to the day of the week:
|
Example
A template author wants to know whether a payment due date falls on a Saturday or Sunday. If it does, they move the payment due date to the following Monday. The following script shows how this works:
IF DAY OF WEEK( Payment Date ) = 6
Payment Date + 2 DAYS
ELSE IF DAY OF WEEK( Payment Date ) = 0
Payment Date + 1 DAYS
ELSE
Payment Date
END IF
Note on compatibility with HotDocs 11
In HotDocs 11, the DAY OF WEEK function returned values from 1-7, where 1 represents Sunday. This difference can cause logic errors when converting templates to work in HotDocs Author. Ensure you update any conditional logic that relies on DAY OF WEEK values to match the new 0–6 scale.