web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Converting date from J...
Power Automate
Suggested Answer

Converting date from JSON parse or compose

(2) ShareShare
ReportReport
Posted on by 2
Using Power Automate, I've got a flow that runs an API call to get a record of data. I'm using this data to update properties in a Sharepoint List, and all is working well so far.
Now I need to change the format of one string from yyyymmdd to mm/dd/yyyy - this is not where the problem is (yet).
 
To change the format, I've tried various approaches, I've split the current value up in 3 parts using first one Compose, and then 3 compose (one for year, one for month and one for day), then I tried a concentate on the output. This did not work - I'm getting an error message which i will get back to.
I've tried do add a compose directly after the Parse JSON
I've tried to add a compose in a "apply to all"
I've tried to move the parse json to "apply to all"
I've tried to add a initialize variable and add variable with a subsequent compose.
 
The compose expression is not the problem yet, cause when I try to save I always get the same message with various action names depending on the approach:
Flow save failed with code 'InvalidVariableOperation' and message 'The inputs of workflow run action 'Compose_1' of type 'Compose' are not valid. The variable 'Compose 2' must be initialized before it can be used inside action 'Compose_1'.'.
 
So I'm stuck, I can use the output from the parse json to update the field in my Sharepoint list, but I Want to have a different format.
I'm using formatDateTime in my compose to try to change the format.
 
Kind of stuck here, anyone have any good explanations for why this shouldnt work?
 
 
Categories:
I have the same question (0)
  • w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
  • Suggested answer
    Jeevarajan Kumar Profile Picture
    17 Most Valuable Professional on at
    I guess its because you're referencing the output of a Compose before it's been initialized or executed. Extract and reformat the date in one Compose using this expression, immediately after Parse JSON.

    E.g.
    formatDateTime(concat(substring(items('Apply_to_each')?['yourDateField'],4,2), '/', substring(items('Apply_to_each')?['yourDateField'],6,2), '/', substring(items('Apply_to_each')?['yourDateField'],0,4)), 'MM/dd/yyyy')
     
  • CU26070618-0 Profile Picture
    2 on at
    thank you @Jeevarajan Kumar, I already tried that earlier cause I thought it would create some "distance", but it doesn't work either.
     
    Here's the code in Compose 1:

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard