Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 exporting date to excel

Author  Topic 

tjonas
Starting Member

17 Posts

Posted - 2014-08-14 : 14:32:57
The date in sql appears like this '07/25/2013 00:00:00' but when I export to excel the date shows like this
'22-JUL-81 12.00.00.000000000 AM'. When I change format in excel nothing happens.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-14 : 14:44:17
How are you exporting to Excel?
Go to Top of Page

tjonas
Starting Member

17 Posts

Posted - 2014-08-14 : 14:52:54
quote:
Originally posted by gbritton

How are you exporting to Excel?



Right clicking on the query results --> export date --> xls
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-14 : 15:03:40
I don't think that's in standard SSMS. I Only see:

Copy
Copy with Headers
Select All
Save Results as ...
Page Setup
Print

I chose Save Results as ...
which brings up a dialog to save a CSV file, I save it, opened it in EXCEL, then change the date column to m/d/yyyy h:mm:ss

It shows as '07/25/2013 00:00:00'

Is that what you did?
Go to Top of Page

tjonas
Starting Member

17 Posts

Posted - 2014-08-14 : 15:18:34
quote:
Originally posted by gbritton

I don't think that's in standard SSMS. I Only see:

Copy
Copy with Headers
Select All
Save Results as ...
Page Setup
Print

I chose Save Results as ...
which brings up a dialog to save a CSV file, I save it, opened it in EXCEL, then change the date column to m/d/yyyy h:mm:ss

It shows as '07/25/2013 00:00:00'

Is that what you did?



No, I exported as xls. It will not let me change in excel
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-14 : 15:46:56
You must have some add-on to let you export directly to Excel.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2014-08-15 : 02:20:56
Use powershell to export the date \ data . That way you can manage the format for the input and how it's written to excel. See some example here:http://www.sqlserver-dba.com/2013/05/sql-server-export-to-excel-with-powershell.html

Another alternative to explore us Import from Excel

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -