cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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

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 III
Dual Super User III

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.

 

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

 

Anonymous
Not applicable

Hi, 

 

I get the following error when implementing the solution:

Capture.JPG

 

What could it be wrong?

 

Thank you again

Hi @Anonymous 

 

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, 

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

Anonymous
Not applicable

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.

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.

Perfect! Glad that it worked for you. 

 

Thanks, 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (8,415)