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
Its working for me too now 🙂
You can close the thread if you are all set with the post.
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.
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.
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.
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.
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.
Still no luck with that. I created a super simple 1 step flow and cannot get this date format to pull in. Very frustrating.
Try just one “h” for the hours, because there is no “0” in front of your 3.
best of luck!
eetuRobo
11
Super User 2025 Season 1
KO-05050229-0
4
John_Mavridis
4
Microsoft Employee