cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
joe904
Helper I
Helper I

Need help formatting date (MM/dd/yyyy) for my Application

Hey guys,

 

I am trying to format the date for my "Select" Action. It displays the year as 2021-11-27 instead of 11/27/2021.

I have tried: formatDateTime('Date_x0020_out_x0020_of_x0020_th', MM/dd/yyyy)

 
But I end up with the following error message:
"The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '{
"Staff Member": "@item()?['Staff_x0020_Name/Value']",
"Date Out of Office": "@formatDateTime('Date_x0020_out_x0020_of_x0020_th', 'MM/dd/yyyy')"
}' failed: 'In function 'formatDateTime', the value provided for date time string 'Date_x0020_out_x0020_of_x0020_th' was not valid. The datetime string must match ISO 8601 format."
 
The date is converted earlier in the app in the "Get Items" action using the Filter Query and it displays correctly. When it goes to the "Select" action it shows again as 2021-11-27. This is the expression that I used:
"formatdatetime(convertFromUtc(utcnow(),'Central Standard Time'),'MM-dd-yyyy')"

 

        "Staff_x0020_Name": {
                "@odata.type""#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                "Id"3,
                "Value""John Smith"
             "Staff_x0020_Name#Id"3,
            "Date_x0020_out_x0020_of_x0020_th": "2021-11-27",
 
joe904_1-1638057315108.png
joe904_2-1638057365538.png

 

joe904_3-1638058735789.png

 

I appreciate any help you can give me.

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User
Super User

Hi!
I would try with the following expression:

formatDateTime(item()?['Date_x0020_out_x0020_of_x0020_th'], 'MM/dd/yyyy')

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

5 REPLIES 5
efialttes
Super User
Super User

Hi!
I would try with the following expression:

formatDateTime(item()?['Date_x0020_out_x0020_of_x0020_th'], 'MM/dd/yyyy')

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Thank You so much!!

SO I ran the app with no problem and it worked as expected. I then began to get error messages later on for some reason. Can you please help me?

joe904_0-1638092875083.png

joe904_1-1638092961849.png

 

 

@joe904 
I would doublecheck if 'Central Standard Time' is between the values allowed by Microsoft. You will find the full list in the following link
Default Time Zones | Microsoft Docs
If the problem persist, my suggestion is to open a new thread following the rule 'one issue, one topic', the reason is unattended, unsolved topics attrack the attention of more superusers, and this one already have several responses.
Thanx for your help making this community great!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



It worked with no problem before I made the change that you suggested. I just re-added the original dynamic value and it did not throw any errors. It has to be some correlation between what you suggested and the filter query code of the "Get Items" action. It obviously does not play well together. I really do appreciate any help you can give me.

 

joe904_0-1638119604269.png

joe904_1-1638119929802.png

 

 

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (1,752)