Solved

SSIS - format date

Posted on 2014-04-08
6
306 Views
Last Modified: 2016-02-10
Hi,

I am new to SSIS, I have SQL 2008 and VS 2008

I am trying to import an excel file into SQL, the datatype of the field is DATE, in the excel, the data looks like this

20140804
20130105
20091025

How can I convert it in SSIS during importing process?  thx
0
Comment
Question by:mcrmg
[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
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39985758
You should not have to.  It should be implicit.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39985777
>How can I convert it in SSIS during importing process?
I recommend against this.  If something throws an error during a combined import and conversion process, then it's more work for you to figure out what generated the error: the data being imported, or the SSIS conversion.

A more supportable approach would be to import it all as a varchar field into a staging table, then once it's imported successfully perform your conversions, to include a methodology to report a conversion failure, e.g. 20140231 not being a valid date.
0
 

Author Comment

by:mcrmg
ID: 39985880
Once I imported them into a staging table, would you recommend I do the conversions in SQL via query or do it in SSIS?

Also, assume there is only one field I need to convert, eg. from 20120522 to 5/22/2012.

What would you recommend to "correct" all the data type, as your post, initially would be all varchar most likely.  Should I create a new table with correct data type then import data from staging table to this table?  thx
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 66

Accepted Solution

by:
Jim Horn earned 400 total points
ID: 39985913
>would you recommend I do the conversions in SQL via query or do it in SSIS?
Yes, but I'll admit that that's a style preference, so your mileage may vary.
It's easier in T-SQL, plus I can do fancy-schmancy things like incrememt a validation_errors (int) column if anything fails a validation, and add English-sounding messages to a validation_message (varchar(1000)) column, then those can be used as the basis of the 'what failed validation?' T-SQL and messanging.

>Also, assume there is only one field I need to convert
In that case, it would be easy enough to have just one table, with columns your_date varchar(100), and your_date_edited (date), and do the conversion as an UPDATE statement.
0
 

Author Comment

by:mcrmg
ID: 39985928
thank you very much
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39985945
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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