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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Format DateTime in Flow
Power Automate
Answered

Format DateTime in Flow

(0) ShareShare
ReportReport
Posted on by 257

I think this is on the right board?
I have a flow where I am Listing Rows and then converting these to HTML format with a connector. I have several date columns and want to reformat the date to 'yyyy-MM-dd'.

This code works sometimes, but not all the time:

formatDateTime(parseDateTime(Item()?['cr2c7_datecreated']), 'yyyy-MM-dd''en-US')
For example, this code works for my column cr2c7_datecreated, but not for these two:
formatDateTime(parseDateTime(Item()?['cr2c7_dateinspected']), 'yyyy-MM-dd', 'en-US')
formatDateTime(parseDateTime(Item()?['cr2c7_datereceived']), 'yyyy-MM-dd', 'en-US')
Anyone know why I would get this error on some datafields and not others? Its happened to me on multiple Flows now with different data Tables from CDS.
Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @MechEng2013 ,

     

    This is PowerApps forum, so I will move this thread to a Power Automate forum.

     

    For your question, if all the columns are Date and time type, they should be easy to convert to the format you need use single formatDateTime function:

    formatDateTime(item()?['cr2c7_dateinspected'], 'yyyy-MM-dd', 'en-US')

    vjefferni_0-1680764309176.png

    vjefferni_2-1680764389293.png

     

    Best regards,

  • MechEng2013 Profile Picture
    257 on at

    Thanks for moving the post. Hopefully i can get some insight to this issue.

     

    This is the formula I use. Sometimes it works and sometimes it gives an error. I can't make sense of it. 

    formatDateTime(item()?['cr2c7_dateinspected'], 'yyyy-MM-dd', 'en-US')
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @MechEng2013 ,

     

    What error did you get? Was the flow failed or giving you incorrect results?

     

    Best regards,

  • MechEng2013 Profile Picture
    257 on at

    Flow Fails:

    MechEng2013_0-1681225202189.png

    The execution of template action 'HTML_Time_to_Inspect' failed. The column values could not be evaluated: 'The template language function 'parseDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#parsedatetime for usage details.'.

     

  • MechEng2013 Profile Picture
    257 on at

    In the same Flow function...

    This works: 

    formatDateTime(parseDateTime(Item()?['cr2c7_datecreated']), 'yyyy-MM-dd''en-US')
    These two do not work:
    formatDateTime(parseDateTime(Item()?['cr2c7_datereceived']), 'yyyy-MM-dd''en-US')
    formatDateTime(parseDateTime(item()?['cr2c7_dateinspected']), 'yyyy-MM-dd''en-US')
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @MechEng2013 ,

     

    The error was just saying that there are blank values in this column. Could you double check in that table? If you really need those fields to be blank, please change the expression to below:

    if(equals(coalesce(item()?['cr2c7_dateinspected'],'NULL'),'NULL'),'',formatDateTime(parseDateTime(item()?['cr2c7_dateinspected']), 'yyyy-MM-dd', 'en-US'))

     

    Best regards,

  • MechEng2013 Profile Picture
    257 on at

    Thanks, but this resulted in the same error... Resulting in datatype NULL, expecting STRING. I am not familiar at all with these types of expressions...

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @MechEng2013 ,

     

    Could you please share the details of the HTML action in your flow?

     

    Best regards,

  • MechEng2013 Profile Picture
    257 on at

    MechEng2013_0-1681391859850.pngMechEng2013_1-1681391881630.png

     

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @MechEng2013 ,

     

    The expression I have tested and it's working perfectly. Please check if the output of Rows-New Received action is empty. I suspect that Odata Filter rows in your flow is not correct. What type is the returning column?

     

    Best regards,

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard