I am using the dos command “w32tm” to convert an Active Directory LastLogonTimestamp into a readable date format. However it gives me something like this: 150215 02:40:10.0843593 – 11/04/2012 12:40:10 PM
How would I go about extracting just the date from the string? So I can have a variable with just “11/04/2012” in it.
Thanks.
You can try the following code. This isn’t the cleanest but it works!
This splits your input string
150215 02:40:10.0843593 - 11/04/2012 12:40:10 PMinto the fragment after the-, passes it into .NET’s DateTime.Parse() function, and then finally outputs the date portion of it.