Solved

SQL to Excel Dates

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL view 2 27
Excel VBA 4 26
Rather Simple Formatting Question 6 23
how to import result to CVS from sql server management studio without comma 2 16
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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