Is there a way to set or create a date/time workflow variable with the current date and current time in a 2013 SPD Workflow?
You would simply use the set workflow variable action and use the current date or use the add time to date action and set 0 days/hours/minutes/seconds to Today.
Made a super-ugly hack (solution?).
Context: I need to get the current Date and time in a 2013 Designer Workflow, and I need it in a loop.
What I've come up with so far: Write something unique to the history list, find that history list item and get item created date.
If you don't mind updating the item it is possible to use the same hack to get Modified of Current Item
I hope I'm doing something wrong, this can't be the correct solution...
Another easy way is to create in your table a calculated column (type date/time) and use the formula =NOW(). Every time the item is triggered by a workflow, this column is updated. And then, you can simply use the content of this field in your workflow.
I've used the "Current Item:Modified" column to get the date as well as the time part to get the also current time.
Modified column is useful within workflow only after any of the column is updated, for example by "Set Field in Current Item" action. Looks like these actions are committed before next action.
So the actions will look like:
Set AnyFieldToUpdateModifiedColumn to AnyValueYouWish Set MyDateAndTimeColumn to Current Item:Modified
I used another list named "Properties", created an item with a unique key and "Modified" time of this item will have the current date and time.
How it works...
This list has 2 columns, one is Title(which is unique and my lookup key) and another is "value" (choice , Y or N), the column can be in any name.
Whenever your workflow starts, it look up this item from this list and check for "value" column. If the "value" column is Y, it will set to N and vise versa. then it will lookup the modified time of this item. This will have the current date and time.
P.S. the date and time is based on where your SharePoint Online is hosted, usually it will return the current US date and time
The best approach is to use a Modified date with two Update Item actions. First to update the list with some dummy data or update the same column, now you will have the latest Modified date with time, which you can use current date time.
I use the Call HTTP-Webservice action to get the current time and date. I send a request to a random web-service and parse the metadata of the respond head. The output is stored in a variable of the type Date and Time.
If you like to read step by step, visit my blog entry: