Solved

SQL to Excel Dates

Posted on 2013-11-15
5
283 Views
Last Modified: 2013-11-25
I am importing dates from MSSQL 2008 R@ to Excel 2013

The dates come in as text and I have to do the "Text to Columns" every time I import.

Is there a way to make them come in as dates so I do not have to convert them every time??
0
Comment
Question by:HDM
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:John_Vidmar
ID: 39652109
If you used Get External Data from the Data ribbon then your import should retain data-types.  In your SQL database-table, are the date-fields defined as datetime or varchar?  If they are defined as varchar then you could CAST into datetime by altering the SQL generated by Excel.
0
 

Author Comment

by:HDM
ID: 39660199
they are defined as date.

I could change these simply if there is a better format.
0
 

Author Comment

by:HDM
ID: 39660204
I am currently using the tab "From Other Sources" under the "Get External Data" tab.

Under that i use the "From SQL server" option
0
 
LVL 11

Accepted Solution

by:
John_Vidmar earned 500 total points
ID: 39662634
Your import technique is correct and should retain data-type.

My MSSQL 2008 R2 database is using collation-sequence SQL_Latin1_General_CP1_CI_AS (not sure if that makes a difference), build 7600. Unfortunately, I do not have Excel 2013, I'm using Excel 2007.

When I import varchar fields that contain only numbers then Excel views that field as text (which is correct, retains data-type). When I import datetime fields then Excel retains date formats (i.e., the final Excel field is not text).  When I import integer fields then Excel formats the field as a number (which is correct).
0
 

Author Closing Comment

by:HDM
ID: 39675310
Thanks!!
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question