cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ian-Murphy
Frequent Visitor

Trying to format Date and Time of Created field for a SharePoint list

I've built a flow that creates a series of HTML tables from multiple lines of a SharePoint list. I've done this by initializing a variable, adding the HTML header, getting the list items, creating a table for each one, adding the HTML footer and then emailing the entire construct. This will eventually be automated, running daily, but for testing purposes, I run it manually.

It's been working fine, but the problem I've encountered is I'm returning the Created field from the SharePoint list and I can't seem to format the date and time into something reasonable.

I've tried using the FormatDateTime expression, but when I do, I don't have the option to select the dynamic content Created field.

I've tried a variety of ways to manually build an expression that would allow me to format the Created field data, but nothing works.

I looked at the code and the dynamic content that I'm trying to format is: 

 

@{items('Apply_to_each')?['Created']}

 

I know I shouldn't wrap the entire thing in the FormatDateTime expression, but every version returns, "The expression is invalid."

I feel like I'm very close, but just can't figure out what I'm doing wrong.

I'm hoping this is something very simple that I'm just missing due to my inexperience.

Thank you, for any suggestions, or help, anyone can provide.

 

Outline of flowOutline of flowAppending HTML codeAppending HTML codeMissing dynamic contentMissing dynamic content

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @Ian-Murphy 

 

Click expression

 

image.png

 

Copy the below expression and paste it. 

 

formatDateTime(items('Apply_to_each')?['Created'], 'dd-MM-yyyy')

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

4 REPLIES 4
abm
Super User
Super User

Hi @Ian-Murphy 

 

Click expression

 

image.png

 

Copy the below expression and paste it. 

 

formatDateTime(items('Apply_to_each')?['Created'], 'dd-MM-yyyy')

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Ian-Murphy
Frequent Visitor

Thank you very much - it worked perfectly!

 

Can you let me know why it worked, and what I was missing? I like learning. 😊

 

The code had the dynamic item listed as @{items('Apply_to_each')?['Created']} and I kept trying to apply FormatDateTime to that and kept getting an error. Why does stripping out the "@" and the Curley Braces allow me to apply the FormatDateTime function?

 

 

Hi @Ian-Murphy 

 

Good question. So for the expressions you don't need to use the @ and { brackets.  Yes when we copy the dynamic content it copies with all those characters. No idea.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Ian-Murphy
Frequent Visitor

It's just that type of weird, secret Microsoft Lore that I knew I'd find here. I'll squirrel it away in my notes.

 

Thanks! 👍

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,834)