Solved

SQL to Excel Dates

Posted on 2013-11-15
5
245 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now