Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

CSV file not displaying date correctly

$
0
0

I have a powershell script that creates a csv file from a SQL database.  I am having trouble with the date format in the file.

My script also takes the csv file and uses ConvertCSV-ToExcel to generate the excel worksheet. I got the function from http://poshcode.org/2123, and formatting information from https://theolddogscriptingblog.wordpress.com/2010/06/01/powershell-excel-cookbook-ver-2/.  I have found nothing on how to format the date in a column.

I don't know what the date format is in the csv file, and I really would like to get it to be what it should be for the associates using the worksheet.

Here is the date in the csv file: 27:42.4

Here is what it should be:  6/24/2015  4:27:42 PM

I know they can format it in the excel sheet, but I think there must be a way that I can format it for them so it displays correctly when they open the file.

How can I format the date in the ConvertCSV-ToExcel function?


Viewing all articles
Browse latest Browse all 6937

Trending Articles