We will now learn about how to use Power Automate to turn a string into a date.
In Power Automate, we’ll begin by manually triggering the flow. This can be added using Instant Cloud Flow.
Next, we’ll add a variable to serve as the initializer. Here, a date will be entered as a text as shown below:
Once more, we’ll add the same action as the Initialize variable, which will divide the day-month-year of a date string into three parts with a comma using the Split() expression. We need to include this stage because Power Automate cannot understand the date string (14, 10, 1999).
We will convert this array into the required date format in this step. We will include the same step as “initialize the variable” for this. We will put an expression that transforms the array in Date in this action.
formatDateTime(concat(variables(‘Vardatestring’)[2], ‘-‘, variables(‘Vardatestring’)[1], ‘-‘, variables(‘Vardatestring’)[0]), ‘dd MMMM yyyy’)
The date format is set to “dd MMMM YYYY” in this case, ensuring that the result will contain the complete month name, i.e. 14 October 1999. Let’s verify this result by testing the flow and saving it.