cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TesDA Helper IV
Helper IV

Deconstruct a Date from a string

I have the following that is a date, but Power Automate thinks its a string:

 

20200217

YYYYMMDD

 

In other systems I could do, Date(substring(1,4), substring(5,2), substring(7,2)) - IE Date(Year, Month, Day)

 

I cant seem to find that functionality in Power Automate. How do I do this here?

 

If its helpful, this is the error Im getting:

 

Unable to process template language expressions for action 'Condition' at line '1' and column '2861': 'In function 'formatDateTime', the value provided for date time string '20200217' was not valid. The datetime string must match ISO 8601 format.'.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Deconstruct a Date from a string

Hi @TesDA 

Try this expression:

 

formatDateTime(concat(substring('20200218',0,4),'-',substring('20200218',4,2),'-',substring('20200218',6,2)),'yyyy-MM-dd')

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

1 REPLY 1
Super User
Super User

Re: Deconstruct a Date from a string

Hi @TesDA 

Try this expression:

 

formatDateTime(concat(substring('20200218',0,4),'-',substring('20200218',4,2),'-',substring('20200218',6,2)),'yyyy-MM-dd')

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

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