SharePoint Designer workflow: Check if today is Saturday or Sunday

Learn how you can use a SharePoint Designer 2010 workflow to check whether the current date (today) is a Saturday, Sunday, or any other day of the week.

ADVERTISEMENTS

In a recent article I showed you how to use the Return fields as option on the Lookup for Number dialog box in a SharePoint Designer 2010 workflow to convert a string to a number.

You can use a similar technique that uses SharePoint Designer workflow variables to check whether today is Saturday or Sunday in a SharePoint Designer 2010 workflow without performing any date calculations.

In this article, you will use the Log to History List workflow action to debug the SharePoint workflow to see how the SharePoint workflow works.

To create a SharePoint Designer workflow that checks whether today is Saturday or Sunday:

  1. Create a new SharePoint Designer 2010 List Workflow and associate it with a SharePoint list you can use for testing purposes.
  2. Click Workflow > Variables > Local Variables and add 2 variables: TodaysDate of type Date/Time and LongDateString of type String.
    Workflow Local Variables dialog box in SharePoint Designer 2010
    Figure 1. Workflow Local Variables dialog box in SharePoint Designer 2010.

  3. Click Workflow > Insert > Action > Set Workflow Variable to add a Set Workflow Variable workflow action to Step 1 of the workflow that sets the TodaysDate variable to the Current date.
  4. Click Workflow > Insert > Action > Set Workflow Variable to add another Set Workflow Variable workflow action to Step 1 of the workflow that sets the LongDateString variable to the value of the TodaysDate variable and return the field as Long Date.
    Lookup for String dialog box in SharePoint Designer 2010
    Figure 2. Lookup for String dialog box in SharePoint Designer 2010.

  5. Click Workflow > Insert > Condition > If any value equals value to add an if statement to the SharePoint workflow, and change the if statement to say:

    If Variable: LongDateString contains Sunday
  6. Place the insertion point in the if statement block, and click Workflow > Insert > Action > Log to History List to add a Log to History List workflow action and set its message to Is Sunday.
  7. Place the insertion point under the if statement block and then click Workflow > Insert > Else-If Branch to insert an else branch under the if statement.
  8. Click Workflow > Insert > Condition > If any value equals value to add an if statement behind the else branch, and change the if statement to say:

    If Variable: LongDateString contains Saturday
  9. Place the insertion point in the else branch, and then click Workflow > Insert > Action > Log to History List to add a Log to History List workflow action and set its message to Is Saturday.
  10. Place the insertion point under the else-if branch and then click Workflow > Insert > Else-If Branch to insert an else branch under the previous else-if branch.
  11. Place the insertion point in the else branch you just added, and then click Workflow > Insert > Action > Log to History List to add a Log to History List workflow action and set its message to Variable: LongDateString.

The final workflow should resemble the following figure:
SharePoint Designer workflow to check if today is Saturday or Sunday
Figure 3. SharePoint Designer workflow to check if today is Saturday or Sunday.

Related Articles

ADVERTISEMENTS