4 Ways to set a date value in a SharePoint Designer workflow

Learn how you can set the value of a date variable or field in a SharePoint Designer workflow to be either a static, dynamic, or calculated date.

ADVERTISEMENTS

The values of dates in SharePoint Designer workflows can be static or dynamic, that is, you can set them to be a specific date (static), or you can calculate them or set them to the value of other date fields (dynamic).

You have 4 options when it comes to setting the value of a date field in a SharePoint Designer workflow. You can use:

  1. The current date (today).
  2. A specific date.
  3. The value of a date field in a list.
  4. The value of a workflow variable that is a date or the result of a date calculation.

This article uses a Set Workflow Variable action to demonstrate how to set the value of a date field in SharePoint Designer.

Setting up the sample

  1. Create a SharePoint Designer workflow in which you want to set or calculate a date.
  2. On the Step 1 screen of the Workflow Designer, click Actions, and select More Actions from the drop-down menu.
  3. On the Workflow Actions dialog box, select Core Actions from the category drop-down list box, select Set Workflow Variable from the actions list, and click Add.
  4. On the Step 1 screen of the Workflow Designer, click workflow variable in the text for the action, and select create a new variable from the drop-down list box that appears.
  5. On the Edit Variable dialog box, type a name for the variable (for example MyDateTime), select Date/Time from the type drop-down list box, and click OK.

1. Set a workflow variable to the current date (today)

To set a workflow variable to the current date:

  1. Click value in the text for the action you created in Setting up the sample.
  2. Click the ellipsis button behind the text box.
  3. On the Date Value dialog box, select Current date, and click OK.

Setting the value of a workflow variable to the current date (today) in SharePoint Designer
Figure 1. Setting the value of a workflow variable to the current date (today) in SharePoint Designer.

2. Set a workflow variable to a specific date

To set a workflow variable to a specific date:

  1. Click value in the text for the action you created in Setting up the sample.
  2. Click the ellipsis button behind the text box.
  3. On the Date Value dialog box, select Specific date, select a date and/or time, and click OK.

Setting the value of a workflow variable to a specific date in SharePoint Designer
Figure 2. Setting the value of a workflow variable to a specific date in SharePoint Designer.

3. Set a workflow variable to the value of a date field in a list

To set a workflow variable to a date value in a list:

  1. Click value in the text for the action you created in Setting up the sample.
  2. Click the formula button behind the text box.
  3. On the Define Workflow Lookup dialog box, define a lookup to the date field you want to set the workflow variable to, and click OK.

Setting the value of a workflow variable to the value of a date field in a list in SharePoint Designer
Figure 3. Setting the value of a workflow variable to the value of a date field in a list in SharePoint Designer.

4. Set a workflow variable to the value of a date calculation

To set a workflow variable to the value of a date calculation, for example, to a date that is 3 days from today:

  1. On the Step 1 screen of the Workflow Designer, click Actions, and select More Actions from the drop-down menu.
  2. On the Workflow Actions dialog box, select Core Actions from the category drop-down list box, select Add Time to Date from the actions list, and click Add.
  3. On the Step 1 screen of the Workflow Designer, click 0 in the text for the action and type 3, click minutes and select days from the drop-down list box, click date, click the ellipsis button.
  4. On the Date Value dialog box, select the current date, and click OK.
  5. On the Step 1 screen of the Workflow Designer, hover over the Add Time to Date action until a drop-down appears, click the arrow, and select Move Action Up.
  6. On the Step 1 screen of the Workflow Designer, click value in the text for the Set Workflow Variable action, and click the formula button behind the text box.
  7. On the Define Workflow Lookup dialog box, select Workflow Data from the source drop-down list box, select the workflow variable that corresponds to the Add Time to Date action you created earlier, and click OK.

Setting the value of a workflow variable to a date calculation in SharePoint Designer
Figure 4. Setting the value of a workflow variable to a date calculation in SharePoint Designer.

Once you’ve set the date of the workflow variable, you can go on to use it in other actions in your SharePoint Designer workflow, such as for example to create a new list item.

Related Articles

ADVERTISEMENTS