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 / Convert text to dateti...
Power Automate
Unanswered

Convert text to datetime - custom format

(0) ShareShare
ReportReport
Posted on by 15

I'm trying to convert text to a datetime field for a date comparison however I keep getting this error "The provided text value can't be converted into a valid datetime."  I've posted my Subflow text below.

 

I'm getting a date from a web browser SSL certificate(The Valid From and Valid To fields on the certificate) and this is the format I'm grabbing.

 

Wednesday, ‎October ‎19, ‎2022 3:49:37 PM

 

When I try to convert it to a datetime field using a custom format(dddd, MMMM dd, yyyy hh:mm:ss tt) I'm getting errors.  I've tried all sorts of things to get this to work but haven't been able to do so.    At one point I just tried hard coding the date so I wasn't messing around with variables and I swear I had it working with the hard coded value.  However when I try to do it again, I'm not having any luck.  Really stumped on this one.

 

FUNCTION Subflow_1 GLOBAL
SET NewVar TO $'''‎Wednesday, ‎October ‎19, ‎2022 3:49:37 PM'''
Text.ConvertTextToDateTime.ToDateTimeCustomFormat Text: NewVar CustomFormat: $'''dddd, MMMM dd, yyyy hh:mm:ss tt''' DateTime=> TextAsDateTime
Display.ShowMessageDialog.ShowMessage Title: $'''Converted Date''' Message: TextAsDateTime Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
END FUNCTION

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Try just one “h” for the hours, because there is no “0” in front of your 3.  

    best of luck!

  • RealPabloBlanco Profile Picture
    15 on at

    Still no luck with that.   I created a super simple 1 step flow and cannot get this date format to pull in.  Very frustrating.

     

    RealPabloBlanco_0-1648555047774.png

     

  • RealPabloBlanco Profile Picture
    15 on at

    The strange thing is, if I get the current date/time, and convert that to the format using 'dddd, MMMM dd, yyyy h:mm:ss tt' and then take that string and convert it back to a DateTime it works.  Anytime I try to put in my own string though I get an error.

  • VJR Profile Picture
    7,635 on at

    A simple date of 29/03/2022 and format of dd/MM/yyyy in the Convert text to Datetime is not working.

    Looks like a bug.

  • Verified answer
    RealPabloBlanco Profile Picture
    15 on at

    I think I figured out the issue and wanted to follow up and share in case anyone comes across this.  I was going to write my own parser via Regex to fix this.  I went to a site(https://regex101.com/) and pasted my string in there and noticed I had unicode characters in there.  When I removed the unicode characters everything worked fine.   I just need to figure out how to strip off the unicode characters in my real script now.

  • VJR Profile Picture
    7,635 on at

    Hi @RealPabloBlanco 

     

    It could be in your case that the issue is due to some characters that you just mentioned. But this is not always the case, because, as I mentioned above, even a simple text like 29/03/2022 in the Convert text to Datetime is giving the same error as yours.

     

    Anyways lets look at your problem. What kind of characters are you seeing and want them to be removed via PAD?

    Do share some screenshots, written text, etc.

  • RealPabloBlanco Profile Picture
    15 on at

    Thanks for the response, but I solved the issue by removing the unicode characters.   I tested your issue above with the date format 29/03/2022 and had no issues.  I'm guessing you have unicode or some other non-ascii characters in your text as well.    I created the single action below and it ran without issue.

     

    RealPabloBlanco_0-1648641334105.png

     

  • VJR Profile Picture
    7,635 on at

    Its working for me too now 🙂

    You can close the thread if you are all set with the 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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard