Hi, I would like to get date from a text line.
text = “some.test.20.01.05.xcddcd.dcdcdcdc.sdsdsd”
[datetime]::ParseExact($text, “y.m.d”, $null)
If successful i should have date in following format 05 Jan 2020
I try above code but i get a error.
Exception calling “ParseExact” with “3” argument(s): “String was not recognized as a valid DateTime.”
At line:7 char:1
- [datetime]::ParseExact($text,‘y.m.d’,[cultureinfo]::InvariantCulture) …
- CategoryInfo : NotSpecified: ( , MethodInvocationException
- FullyQualifiedErrorId : FormatException