cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Metamorph
New Member

Date Conversion in Power Automate

Hi

 

I have looked through a number of posts on this and tried a lot of what I found but cannot find what I am looking for. 

 

I have created a form and the date in the form shows as dd-mm-yyyy but when I put the response into a power automate flow it changes the format to yyyy-mm-dd and any changes I make fail as I get a message saying it must be ISO8601 compliant. 

 

Does anyone out there know how I can format the date so it is displayed as dd-mm-yyyy

 

Any help would be really appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Metamorph 

Please note that in the picture below, there are two Composes and write the formula in Compose 2.

vLilyWmsft_0-1634197749852.png

Best Regards.

View solution in original post

14 REPLIES 14
CFernandes
Super User
Super User

Hey @Metamorph 

 

You can use the expression - 

 

formatDateTime(triggerBody()?['Date'],'dd/MM/yyyy')

 

CFernandes_0-1634131786108.png

 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @CFernandes 

Thanks for the quick reply. I am new to doing this, but I cannot see the full expression and would this step be after get response details?

 

Thank you

 

Metamorph
New Member

Sorry got string in an email. I have tried that and I got

 

Unable to process template language expressions in action 'Compose' inputs at line '1' and column '15952': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

@Metamorph It seems that the value returned by your variable is null.

 

Can you add a compose > add the variable and see if it returns correct value?

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Metamorph
New Member

I tried that and I got the following

Metamorph_0-1634134531361.png

 

Hey Mate @Metamorph 

 

Your date Time item is not set.

 

Please Fill in the form again make sure your Date Time field is filled and then run your flow and you will see the existing value.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

P.S. take a look at my blog here and like & subscribe to my YouTube Channel thanks.

Hi

I completed the form again and filled in every field on it but the flow has still failed with the same error. ☹️

Hi @Metamorph 

Please take a try refer to the screenshot below.

vLilyWmsft_0-1634176273172.png

Expression:formatDateTime(outputs('Compose'),'dd-MM-yyyy')

vLilyWmsft_1-1634176286967.png

Result:

vLilyWmsft_2-1634176371835.png

Hope the content above may help you.

Best Regards

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

Hi

 

I tried that and got: 

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The 'inputs' property of template action 'Compose' at line '1' and column '18122' is not valid. The action cannot reference itself.'.'.
Metamorph_0-1634197535254.png

 

Hi @Metamorph 

Please note that in the picture below, there are two Composes and write the formula in Compose 2.

vLilyWmsft_0-1634197749852.png

Best Regards.

Hi @v-LilyW-msft 

Yes that worked, thanks so much. If I have more than one date I need to convert do I have to create 2 compose steps for each date or can it be done within the 2 steps you advised to create?

Thanks again

Hi @Metamorph 

You can combine two steps into one step.

First. Delete outputs('Compose') 

vLilyWmsft_0-1634199248895.png

Then click Dynamic content.

vLilyWmsft_1-1634199327115.png

Then select the response which you want.

vLilyWmsft_3-1634199571587.png

Finally click update.

vLilyWmsft_2-1634199397268.png

Compose can be deleted and only Compose 2 is retained. 

vLilyWmsft_4-1634199666322.png

 

vLilyWmsft_0-1634200082961.png

Best Regards.

 

 

Thank you. But what if I have 2 dates that need converting Date1 and Date2 can this be done in one compose or do I need one for each?

You need to format two dates in two Composes.

Best Regards. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,696)