1

I'm new to PowerShell and I have a CSV file where I need to change the format of the dates in 2 columns (as shown in the example below) to the format dd/mm/yyyy.

"First Name","Last Name","Employee Number","Course Name","Completion Status","Date_Started","Completion_Date"

Joe,Bloggs,8632,"Test Name",Complete,"26 Nov 2015","26 Nov 2015"

Does anyone know how to achieve this using PowerShell?

1 Answer 1

1

You can try this :

Import-Csv D:\temp\test.csv | % {$_.Date_Started = ([datetime]($_.Date_Started)).ToString('dd/MM/yyyy');$_.Completion_Date = ([datetime]($_.Completion_Date)).ToString('dd/MM/yyyy');$_} | Export-Csv 'D:\temp\testBis.csv' -NoTypeInformation

You can try [datetime]::ParseExact(...) to parse special dates.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.