cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GuilleATT
Level: Powered On

Convert string to date

Hi,

 

I have a string that comes from an Output like this: 

["05/22/2019 00:00:00"]

 

And I would like to know the day of the week and the month written in letters to be sent on an email like this:

 

"Tomorrow Wednesday, the 22nd of May, ..."

 

There is no way I could make it work 😞

 

Thank you for your help!

 

Guillermo

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Convert string to date

Note: If the string is coming in the type: 

["05/22/2019 00:00:00"]

you need to do another compose action to extract just the date and time by using :

substring(variables('re'), 2, 19)

here 're' is my variable with the string (["05/22/2019 00:00:00"])

your next compose action will be:

formatDateTime(outputs('Compose_2'), 'dddd, dd''nd'' ''of'' MMMM')

Here compose_2 is the output of the substring. 

 

Hope this helps!

 

Thanks, 

View solution in original post

8 REPLIES 8
Dual Super User
Dual Super User

Re: Convert string to date

Hi,

 

You can follow the steps as shown in the screenshot to compose the date and time accordingly. 

 

Expression: formatDateTime(variables('re'), 'yyyy MMMM dddd') 
This will give you the desired format : formatDateTime(variables('re'), 'dddd, dd''nd'' ''of'' MMMM')

The expression can be modified.

 

dateTime.png

 

Thanks, 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 
Highlighted
Super User
Super User

Re: Convert string to date

An alternative to @yashag2255's answer  is to use the convert time zone action (see image below):

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

ConvertTomeZone2.png

 

GuilleATT
Level: Powered On

Re: Convert string to date

Hi, 

 

I get the following error when implementing the solution:

Capture.JPG

 

What could it be wrong?

 

Thank you again

Dual Super User
Dual Super User

Re: Convert string to date

Hi @GuilleATT 

 

Please check that the date time string is of the form :

 

05/22/2019 00:00:00

Add a compose action with the expression: 

formatDateTime(variables('re'), 'dddd, dd''nd'' ''of'' MMMM')

Please note that 're' is a variable that I have created. 

 

Can you post a screenshot of your compose action so that we can assist you better? 

 

Thanks, 

Dual Super User
Dual Super User

Re: Convert string to date

Note: If the string is coming in the type: 

["05/22/2019 00:00:00"]

you need to do another compose action to extract just the date and time by using :

substring(variables('re'), 2, 19)

here 're' is my variable with the string (["05/22/2019 00:00:00"])

your next compose action will be:

formatDateTime(outputs('Compose_2'), 'dddd, dd''nd'' ''of'' MMMM')

Here compose_2 is the output of the substring. 

 

Hope this helps!

 

Thanks, 

View solution in original post

GuilleATT
Level: Powered On

Re: Convert string to date

hi, 

 

it worked!!

 

Capture1.JPGCapture2.JPG

 

Compose 4 does a Union to get unique values

Then it is saved on a variable of type string

And then the replacing you suggested.

Finally formatDateTime(...) worked!!!

 

Awesome, I will validate your response.

Super User
Super User

Re: Convert string to date

But then surely if you use ''nd'' and the date is the 4th of the month you'll get the wrong result. 4nd isn't right!

formatDateTime(outputs('Compose_2'), 'dddd, dd''nd'' ''of'' MMMM')

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

Dual Super User
Dual Super User

Re: Convert string to date

Perfect! Glad that it worked for you. 

 

Thanks, 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,951)