Thursday, September 1, 2011

SPD Workflow: Get Quarter based on Date

From time to time you need some output data that are not obviously available in SharePoint Designer when using out of the box actions. Such an output was needed the other day, and it was setting which quarter the current item was updated. The quarter should be used for different aggregations. With only SharePoint Designer and OOTB actions it didn't look like an easy task, but it turned out it was.

What was need was an constant variable, constant in the terms of characters returned. After some testing on different return types I figured out that ISO Formatted always returns the same amount of characters. And with another OOTB action, the Extract Substring of String from Index with Length.

First create a variable of type String, in the example its called "finnMnd":


I have used a parameter of type Date, "Start Dato", this could be any field of type Date. And the Return field as should be ISO Formatted.















After that we need to extract the month, and the month is always starting on position 6 with length of 2.












We have the number for the month in the variable "finnMnd". Now its only needed to do some checks and set a variable to 1. Quarter  2. Quarter etc with use of the condition "If any value equal value".























No comments:

Post a Comment