Excel isn't reading sql exported csv properly
Posted
by
mhopkins321
on Stack Overflow
See other posts from Stack Overflow
or by mhopkins321
Published on 2012-12-11T23:01:47Z
Indexed on
2012/12/11
23:03 UTC
Read the original article
Hit count: 159
I have a batch file that calls sqlcmd to run a command and then export the data as a csv. When viewed in a cell the trasancted date for example shows 35:30.0
but if you click on it the formula bar shows 1/1/1900 2:45:00 PM
. I need the full timestamp to show in the cell. Any ideas?
The batch file is the following
sqlcmd -S server -U username -P password -d database -i "D:\path\sqlScript.sql" -s "," > D:\path\report.csv -I -W -k 1
The script is the following. Now I currently have them cast as varchars, but that's simply because i've tried to change it a bit. Varchar doesn't work either.
SET NOCOUNT ON;
select top(10)BO.Status,
cast(tradeDate AS varchar) AS Trade_Date,
CAST(closingTime AS varchar) AS Closing_Time,
CAST(openingTime AS varchar) AS openingTime
FROM GIANT COMPLICATED JOINS OF ALL SORTS OF TABLES
© Stack Overflow or respective owner