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 / Converting text string...
Power Automate
Answered

Converting text string to date format

(2) ShareShare
ReportReport
Posted on by 6
I am adding files to a document library and part of the file name includes a date:  e.g. EmployeeName_documenttype_20250416.pdf.  I have used the split function to split the employee name, doctype and the date, and have an output of "20230701" for the date, but now I'm struggling with getting "20230701" into a date format to populate a "Document Date" column in my library.  I've tried formatDateText, parsing the JSON and the concat function but always a different message and seem to be going in circles.  How do I need to modify my Compose 1 to format the date, or maybe I need to add an action between Compose 1 and Update File Properties?
Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Can you show the part of your flow where you are using the equivalent of formatDateTime(outputs('Compose1'), 'yyyy-MM-dd')
    Did you add validation to ensure that the split string will always transform to a valid date?
  • Suggested answer
    w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
    can you try this
    concat(
      substring('20230701', 0, 4), '-', 
      substring('20230701', 4, 2), '-', 
      substring('20230701', 6, 2)
    )
  • Chriddle Profile Picture
    8,443 Super User 2025 Season 2 on at
    There is a function for that: formatDateTime()
  • stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    Assume that in "20230701", "07" is the month, otherwise it will be different .
     
    parseDateTime(
    concat(
        substring(triggerBody()?['text'], 0, 4), '-',
        substring(triggerBody()?['text'], 4, 2), '-',
        substring(triggerBody()?['text'], 6, 2)
      ),
      'sv-se'
    )
    this this one.
  • Verified answer
    w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
    parseDateTime('20190521', 'fr-fr', 'yyyyMMdd')✅
    parseDateTime('20190521', 'fr-fr', 'ddMMyyyy')❌
    parseDateTime('21052019', 'fr-fr', 'ddMMyyyy')✅
    parseDateTime('21052019', 'fr-fr', 'MMddyyyy')❌
    parseDateTime('21052019', 'fr-fr', 'yyyyMMdd')❌
    from 
  • Chriddle Profile Picture
    8,443 Super User 2025 Season 2 on at
    parseDateTime(
    	slice(
    		'EmployeeName_documenttype_20250416.pdf',
    		-12, -4
    	),
    	'es-es', 'yyyyMMdd'
    )
  • MK-16042032-0 Profile Picture
    6 on at
    Thanks for all the suggestions.  Chriddle had the quickest and easiest solution.  I was able to add another compose to get this functioning.
  • w.p Profile Picture
    8,339 Super User 2025 Season 2 on at

    You mentioned Chriddle but you didn’t give him a like or credit.
    You may have marked the wrong one, or you could select more than one answer.

  • MK-16042032-0 Profile Picture
    6 on at
    Oh, my bad.  I'm new to this community.  I added the like but I already had the checkmark for "does this answer your question".  Is that where I give credit or somewhere else?
     
  • w.p Profile Picture
    8,339 Super User 2025 Season 2 on at
    Thanks for your response. I thought you marked the wrong post—the solution came from Chriddle's post.
     
     

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard