Avatar of Chris Johnsen
Chris Johnsen
 asked on

Convert yyyy-MM-dd to MM/dd/yyyy in entire cave file using powershell

Need to convert a file that was exported from excel that is about 98k rows and some of the dates are correct but others are.  Would like to be able to run a simple convert item on the csv files  but not able to get this to work 100% as needed using powershell.

Tried

Import-Csv -Path ‘c:\mycsvfile.csv’ |

 Select-Object -Property @{

   Name = ‘my column name’

   Expression =  {

      $_.’my column name’ | 

        Get-Date. -Format  ‘ yyyy-MM-dd’ |

        Get-Date -Format  ‘MM/dd/yyy’

  }

},  *. | Export-Csv -Path ‘c:\mycsvfile_new.csv -NoTypeInformation


Any help would be great full as I no not really want to have to use notepad++ to update all of the incorrect values.


Thank you


Powershell

Avatar of undefined
Last Comment
Chris Johnsen

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Qlemo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Chris Johnsen

ASKER
Thank you for the update, this did exactly what I needed it to.  Yes I am aware of the format and that it is the correct one but it is not what the business wants to see as the end result.

Thank you again for the quick and easy response.
Your help has saved me hundreds of hours of internet surfing.
fblack61