I got a CSV file with a date column with the format dd/MM/YYY HH:mm:ss, e.g. 14/11/2016 00:00:00.
I'm trying to batch convert the formating on that column to an ISO-8601 date format: YYYY-mm-dd HH:mm:ss
I have tried: ( I have edited I had an error on input string format...)
Import-Csv someCSV.csv | % {
$_.'[Date]' = ([datetime]::ParseExact(($_.'[Date]'),"dd/MM/YYYY HH:mm:ss").ToString('yyyy-MM-dd HH:mm:ss'))
} | Export-Csv 'C:\testBis.csv' -NoTypeInformation
I'm getting an error:
Cannot find an overload for "ParseExact" and the argument count: "2".
At line:1 char:69
+ ... Date]' ; ([datetime]::ParseExact(($_.'[Date]'),"dd/MM/YYY HH ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
I've had a look and tryed with Try parse and sever few ideas but nothing seam to work.
I dont know what I'm going wrong. any suggestions?