Importing from CSV and sorting by Date
Posted
by Andrew Rice
on Server Fault
See other posts from Server Fault
or by Andrew Rice
Published on 2010-05-14T15:13:28Z
Indexed on
2010/05/14
15:26 UTC
Read the original article
Hit count: 337
powershell
I have the following script that parses an HR output file looking for employees and outputs information such as Hire Dare, First Name, Last Name, Supervisor etc.
The problem I have is that in the current format I think the Hire Date column is being treated as a string so in effect it orders the output by month (i.e. 1/1/01 comes before 2/2/98). Is there a way to map that column to a date/time so it sorts properly?
Import-CSV -delimiter "`t" Output.tab | Where-Object {$_.'First Nae' -like '*And*'} | Sort-Object 'Hire Date' | ft 'Hire Date', 'First Name'
© Server Fault or respective owner