cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sienna28
Post Patron
Post Patron

Problem with formatting a date

I did a GetItems from my SharePoint list

 

One of the columns is a date value that I need to format.

 

I have tried various expression date formats.

 

formatDateTime('DateInspection', 'dd-MM-yyyy hh:mm tt')

formatDateTime(utcnow(),'D')


However I keep getting an error of
the value provided for date time string 'DateInspection' was not valid.
The datetime string must match ISO 8601 format.'.

 

Any help appreciated

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ccc333ab
Solution Sage
Solution Sage

Yes, that is correct. You can just use 

formatDateTime(outputs('Get_item')?['body/DateInspection'],'dd-MM-yy')

View solution in original post

11 REPLIES 11
ccc333ab
Solution Sage
Solution Sage

What is the datatype of [DateInspection]? Is there any possibility it is not of type Date (i.e., its a String)? 

 

Maybe just before the formatDateTime you can add in a Compose action, adding DateInspection as the Input, so that we can see what value is being fed into the format expression. 

powercorner
Resolver III
Resolver III

Hello @sienna28 ,

 

Is this the syntax you are using in the flow: formatDateTime('DateInspection', 'dd-MM-yyyy hh:mm tt')?

If so you are not giving the formatDateTime the TimeString you are actually just giving him the string 'DateInspection'. Please screenshot this part of your flow. I think we can fix this quick!

 

With regards

Kevin

Thank you for replying.

I have attached a screenshot below

flow date issue.PNG

powercorner
Resolver III
Resolver III

Hey @sienna28 Its almost right.

 

It should be: 

 

 

formatDateTime(outputs('Get_item')?['body/DateInspection'],'dd-MM-yy hh:mm tt')

 

 

cause you need to reference the output of the Get Item action.


With regards
Kevin

 

 

--------------------------------------------------------------------------------
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.

Thanks for replying.

I pasted your suggestion in , but it says the expression is invalid.

Unsure what could be wrong here.

 

 

ccc333ab
Solution Sage
Solution Sage

There was a slight typo with @powercorner formula (an extra bracket): 

   formatDateTime(outputs('Get_item')?['body/DateInspection']),'dd-MM-yy hh:mm tt')

Try this instead: 

 

formatDateTime(outputs('Get_item')?['body/DateInspection'],'dd-MM-yy hh:mm tt')

 

 

hey @sienna28 ,

 

@ccc333ab is right. There was a typo. I corrected it:

formatDateTime(outputs('Get_item')?['body/DateInspection'],'dd-MM-yy hh:mm tt')

Perfect - works well 

 

Thank you

Thank you

 

Works well.

 

I assume if I just want the date, then I just remove the 

time part

 

ccc333ab
Solution Sage
Solution Sage

Yes, that is correct. You can just use 

formatDateTime(outputs('Get_item')?['body/DateInspection'],'dd-MM-yy')

View solution in original post

hey @sienna28 ,

 

you are welcome. Thats right!

 

Help the community and mark the answer as solution please 🙂

 

With regards
Kevin

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution”. This will help the whole community. If I could help you out please give my post a Thumbs Up. 🙂

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,161)