?
Solved

SQL to Excel Dates

Posted on 2013-11-15
5
Medium Priority
?
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

762 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