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 / formatDateTime functio...
Power Automate
Unanswered

formatDateTime function in Power Automate

(0) ShareShare
ReportReport
Posted on by 12

I am constructing a flow to save email attachments to a sharepoint library. The file name should be saved along with its received time. So I'm using formatDateTime function to format the received date time of the attachment in the compose action.
This is the expression that I've used - formatDateTime(triggerOutputs()?['body/receivedDateTime'],'dd/MM/yyyy hh:mm tt')
It actually works fine and changed to the required format I mentioned, but while getting saved in SharePoint, symbols like '/' and ':' were replaced with '_'. That could be due to some restrictions on file name in sharepoint, but is there a way to save the file as per I desire??

Categories:
I have the same question (0)
  • v-mingkz-msft Profile Picture
    Microsoft Employee on at

    Hi @Kaviya16,

    The error message shows that your input string is 'Let me first tell you the overall c.txt', obviously you can not convert it to time stamp.

    Please offer me more information about your flow, and your input string.

     

    Best Regards,

    Kyrie

  • v-wenjuan-msft Profile Picture
    Microsoft Employee on at

    Hi @Kaviya16 ,

     

    Could you share screenshot of your current flow?

    formatDateTime function can only be adapted to datetime value. Suppose your trigger is "When a new email arrives" and "Received time" originate from it, you can try this function:

     

    concat(items('Apply_to_each')?['name'],'-',formatDateTime(triggerOutputs()?['body/receivedDateTime'],'dd/MM/yyyy hh:mm:ss'))

     

     

    Community Support Team _ Wenjuan Zou

    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • ManishSolanki Profile Picture
    15,091 Super User 2025 Season 2 on at

    Hi @Kaviya16 

     

    Here is the sample flow for your reference:

    ManishSolanki_0-1688982296745.png

    Expression used for transforming the name of the file and to include the original file extension:

    concat(formatDateTime(utcNow(),'dd/MM/yyyy HH:mm tt'),'.',last(split(items('Apply_to_each')?['name'],'.')))

    One more observation, when file is created in SharePoint, it replaces '/' & ':' characters with underscore '_'. It might be the case that those characters are not allowed in file names.

    The output file created using the above expression is:

    ManishSolanki_1-1688982542539.png

     

     

    If this helps & solves the problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • Kaviya16 Profile Picture
    12 on at

    Actually I am the one who made a mistake and resolved the previous issue which I asked solution for. Now I've edited my question and need help with this one.
    Thanks for your given responses anyways!

  • Kaviya16 Profile Picture
    12 on at

    So, this suggested expression would save my file with the name 'receiveddatetime.fileformat' right?? But I want to save the file with its name along with the receiveddatetime in a proper format that I've used in my formatDateTime function : (

  • Verified answer
    v-wenjuan-msft Profile Picture
    Microsoft Employee on at

    Hi @Kaviya16 ,

     

    The mentioned characters are not allowed to use in filename in SharePoint.

    Refer to below link for further information:

    Restrictions and limitations in OneDrive and SharePoint - Microsoft Support

     

    Community Support Team _ Wenjuan Zou

    If this post helps, then please consider Accept it as the solution to help the other members find it.

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 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard