?
Solved

Excel Import Data from SQL- Date comes across as text

Posted on 2013-12-31
6
Medium Priority
?
2,603 Views
Last Modified: 2014-01-02
Hello experts,

I'm importing data from an MS SQL database into an Excel sheet using data connection. The SQL table includes a Date column, but this column comes to Excel as text rather than date.

Is there any way I can fix this issue?

The good news is..I can loop through each and every cell in that particular column using VBA code, so perhaps this could help coming up with a solution.

Thank you,
Hani
0
Comment
Question by:Mehawitchi
[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
6 Comments
 
LVL 43

Expert Comment

by:Rob
ID: 39749403
Is it stored as a date type on your database? What is the format it's coming back ?
0
 
LVL 43

Expert Comment

by:Rob
ID: 39749558
I'm suspecting it's something like "yyyy-mm-dd"? In which case you'll need to parse the date as a string in your sql to the following format "mm/dd/yyyy" That should be enough for excel to recognize it as a date
0
 
LVL 1

Expert Comment

by:innosys
ID: 39750346
you can separate the string into 3 columns and rebuild the date depending on the date format
like mid(e1,0,2) as month and mid(e2,4,2) as day and mid(e2,7,4) as year and then rebuild the date in excel sheet

it will help and it isvery good to solve this issue
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 39750365
The easiest is to format the date to how excel likes it using the SQL Convert function in your SQL.

Eg

Select *, CONVERT(VARCHAR(10), my_date_column, 103) as newdate FROM mytable;

The 103 indicates that it will be formatted as dd/mm/yyyy
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 39750821
as rob jurd suggested, please advise the column format in SQL server table.

But for me, I ALWAYS format dates as yyyy-mmm-dd  as it is unambiguous.

For me in Oz, the std display format is dd/mm/yyyy, but that doesn't import correctly.  So if i use dd/mmm/yyyy, the display is ok, and all conversions and imports work fine too.
0
 

Author Comment

by:Mehawitchi
ID: 39750839
Thanks to all contributions
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

764 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