How to convert string to Date using Power Automate?

In this Power Automate tutorial, I will teach you how to convert String to Date using Power Automate.

Scenario:

The flow triggers manually, sometimes, users enter the date in a string format, so we will use the format DateTime to convert it into a date with different date formats.

To achieve this, follow the below steps:

How to convert string to Date using Power Automate

Here we will discuss how to convert a string into a Date using Power Automate Flow. This is an example of “power automate convert string to date dd/mm/yyyy”.

Step-1:

  • Initially, log in to Power Automate flow using the credentials, and select +Create -> instant cloud flow.
  • Enter the flow name Choose Manually trigger a flow and click on the create option as highlighted below:
power automate convert string to date dd/mm/yyyy

Step-2:

Expand the Manually trigger action, and add a text input to enter the date value as a string.

convert string to datetime format power automate

Step-3:

Select +New Step -> Add an action to initialize variable, choose the data type as a string, and add the dynamic content value of StringDate.

convert string to datetime format power automate

Step-4:

Add a compose action, pass the below expression to convert the date string into an array, and split the day-month-year with a slash using the Split() expression.

split(variables('VarStringDate'),'/')
convert string to datetime format power automate

Step-5:

  • Select +New Step -> Add an action to initialize variable and choose the data type as a string. Date datatype is not available while initializing the variable.
  • And in the value section pass the below expression to display the date in dd MMMM yyyy format.
formatDateTime(concat(outputs('Compose')[2], '-', outputs('Compose')[1], '-', outputs('Compose')[0]), 'dd MMM yyyy')
convert string to Date using Microsoft flow

Add a compose action and pass the dynamic content variable name as input to see the result.

Example to convert string to Date using Microsoft flow

Step-6:

Below, we will see the examples with different date formats:

Case-1: (dd MMM yyyy)

Save and Run the flow by selecting the run flow option. Enter the String date and click the run flow option.

Power Automate convert string to Date

Once our flow ran successfully like below, we can see that the output of compose action displays the date value based on the selected date format.

Power Automate convert string to Date example

Case-2: (yyyy MMM dd)

Similarly, follow step-5 and add the below expression with the date format of yyyy MMM dd.

formatDateTime(concat(outputs('Compose')[2], '-', outputs('Compose')[1], '-', outputs('Compose')[0]), ' yyyy MMM dd')

Save and run the flow. Enter the date and click the run flow option:

convert string to Date using the flow

In the compose action output section, we can see the expected result in the date format.

Example to convert string to Date using the flow

Case-3: (MMM dd yyyy)

We also see a few different date formats, Follow step-5 and add the below expression with the date format of MMM dd yyyy.

formatDateTime(concat(outputs('Compose')[2], '-', outputs('Compose')[1], '-', outputs('Compose')[0]), 'MMM dd yyyy')

Enter the date and click the run flow option:

convert string to Date using Power Automate

In the compose action output section we can see the expected result in the mentioned date format.

convert string to Date using Power Automate flow

Case-4: (dd MMMM yy)

Now we are going to see an example for the mentioned date format dd MMMM yy, follow Step-5, and pass the below expression.

formatDateTime(concat(outputs('Compose')[2], '-', outputs('Compose')[1], '-', outputs('Compose')[0]), 'dd MMMM yy')

Enter the date and click the run flow option:

Example to convert string to Date using Power Automate flow

We can see the expected result in the mentioned date format in compose action output section.

Example to convert string to Date using Power Automate

Case-5: (yyyy MMM)

Similarly, follow step-5 and add the below expression with the date format of yyyy MMM

formatDateTime(concat(outputs('Compose')[2], '-', outputs('Compose')[1], '-', outputs('Compose')[0]), 'yyyy MMM')

Enter the date and click the run flow option:

Example to convert string to Date using the Power Automate flow

In the outputs of compose action, we see it displays the date value based on the selected date format.

power automate convert string to date dd/mm/yyyy

This is how to convert a string into a Date using Power Automate.

In this Power Automate tutorial, we have learned how to convert String to Date using Power Automate. We saw here 6 different date format that you can follow while converting string to date using Power Automate.

You may also like:

>