cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AlessandroP
Helper II
Helper II

How to convert string dd/mm/yyyy hh:mm to datetime with format dd/mm/yyyy hh:mm

Dear Experts

 

I have been practising with datetime conversion from string to datetime format and I am really struggling

 

Below the flow 

 

AlessandroP_0-1613307556161.png

Formatdatetime(variables('DateTime'),'dd/mm/yyyy HH:MM')

 

but when I run it , I get the following error

 
 

Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2437': 'In function 'formatdatetime', the value provided for date time string '14/02/2021 15:32' was not valid. The datetime string must match ISO 8601 format.'.

 

Any help please?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jinivthakkar
Super User
Super User

@AlessandroP 

 

jinivthakkar_0-1613322723151.png

jinivthakkar_1-1613322777691.png

jinivthakkar_2-1613322814878.png

 

Expressions used 

split(variables('Datetime'),' ')

split(outputs('Compose_2')[0],'/')

formatDateTime(concat(outputs('Compose_4')[2],'-',outputs('Compose_4')[1],'-',outputs('Compose_4')[0],' ',outputs('Compose_2')[1],':00'),'yyyy-MM-dd HH:mm')

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

 

View solution in original post

5 REPLIES 5
Hardesh15
Super User
Super User

@AlessandroP  As clear from error message your date is not in ISO 8601 format. you may need to break it apart and rearrange it to the correct formatting to use it as a DateTime string. Make you date in this format- 2021-02-14T11:59:00
2021-02-14T11:59:00Z
20210214T115900Z

Please 'Thumbs Up' the posts that helped you and 'Mark as Solution' if my post answered your question.

@Hardesh

That is the error I am getting .. my question is how do I do that ?

@AlessandroP You need to use split expression here.

Hardesh15_0-1613322473623.png

Hardesh15_1-1613322504693.png

Please 'Thumbs Up' the posts that helped you and 'Mark as Solution' if my post answered your question.

@Hardesh

 

 

jinivthakkar
Super User
Super User

@AlessandroP 

 

jinivthakkar_0-1613322723151.png

jinivthakkar_1-1613322777691.png

jinivthakkar_2-1613322814878.png

 

Expressions used 

split(variables('Datetime'),' ')

split(outputs('Compose_2')[0],'/')

formatDateTime(concat(outputs('Compose_4')[2],'-',outputs('Compose_4')[1],'-',outputs('Compose_4')[0],' ',outputs('Compose_2')[1],':00'),'yyyy-MM-dd HH:mm')

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

 

Thank you Sir, you are a star

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.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,558)