Solved

date conversion in SSIS package

Posted on 2011-03-25
5
574 Views
Last Modified: 2012-05-11
Dear Experts,
I have a file that was originally coming through with date formats as (mm/dd/yyyy) vs. the new format (yyyymmddhhmmss???). I have attached the new file. Can you please suggest how I can change the date format to the new format.
Please find attached the picture of the flow that I was using for the old file with date formats as (mm/dd/yyyy) . Please let me know how I can change the date format, should I add a derived column and then change the field types?
Thanks!! main_flow data_conversionSERIAL-DAILY.txt
0
Comment
Question by:sqlcurious
  • 4
5 Comments
 
LVL 15

Assisted Solution

by:Aaron Shilo
Aaron Shilo earned 500 total points
ID: 35221439
hi

make it simple add a derived column and CAST to the needed format.
0
 

Assisted Solution

by:sqlcurious
sqlcurious earned 0 total points
ID: 35223759
Hi tried this, but it is giving an error
(DT_DBTIMESTAMP)(SUBSTRING(IntervalStartDateTime,5,2) + "-" + SUBSTRING(IntervalStartDateTime,7,2) + "-" + SUBSTRING(IntervalStartDateTime,1,4) + " " + SUBSTRING(IntervalStartDateTime,9,2) + ":" + SUBSTRING(IntervalStartDateTime,11,2) + ":00")


0
 

Accepted Solution

by:
sqlcurious earned 0 total points
ID: 35233694
shamu....this should work...

(DT_DBTIMESTAMP)(SUBSTRING([SHIP DATE],1,4) + "-" + SUBSTRING([SHIP DATE],5,2) + "-" + SUBSTRING([SHIP DATE],7,2) + " " + SUBSTRING([SHIP DATE],9,2) + ":" + SUBSTRING([SHIP DATE],11,2) + ":" + SUBSTRING([SHIP DATE],13,2) + "." + SUBSTRING([SHIP DATE],5,3))
0
 

Author Comment

by:sqlcurious
ID: 35233703
And there is one record in your text file with BPRA# 5045105 which has null return date and null shipdate….so that record will fail in the derivedcolumn transformation…so try to redirect that record to the error text file….hope this helps….
0
 

Author Closing Comment

by:sqlcurious
ID: 35304297
problem solved
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

786 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