blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

SSIS Junkie

SSIS: Parsing datetime values

I was reading a post on the SSIS forum where someone was having trouble casting a string into a datetime value. The problem was that although the value in the string looked like a datetime value, it wasn't in a format that could be understood by SSIS.

 

That got me thinking, what values ARE valid values for SSIS to be able to cast as a datetime. So I knocked up a quick SSIS package to try and demonstrate. Its very simple as you can see here:

Simply I have a script component that puts some string values into the pipeline. The Derived Column component tries to cast them as DT_DBTIMESTAMP. Any that fail end up going down the error output. And I've got some data viewers to take a look at those that pass and those that fail. You can see those data viewers here below:

Straightaway you can see the values that passed and those that didn't so I won't waste time writing them out here again. If you want to have a go with this yourself with some values of your own then download the demo package from here.

-Jamie

 

Published 26 June 2006 09:55 by jamie.thomson
Attachment(s): 20060626ValidDatetimeStrings.zip

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Unwelcome reality said:

The extreme lack of detail makes this absolutely useless.  Just a fluff piece to promote mickeysoft.  If it was 'very simple', it wouldn't be necessary to download a demo program JUST TO SEE HOW TO DO A SIMPLE DATE FORMAT CONVERSION.  Apparently that was just too complex to put in words, here.

Face it.  SSIS is a joke.  Why spend 3 days figuring out how to configure a package like this, when you can write your own translation code in 3 hours?

January 18, 2008 18:56
 

jamie.thomson said:

If you have something constructive to say then I'd welcome it but I don't appreciate insults or aspersions cast about what I write. I spend a lot of time writing this blog - if what I write isn't useful to you then please simply move along or pose a question and I'll try and answer it, I'd thank you for not ramming it down my neck.

-Jamie

January 18, 2008 19:11
 

Andy said:

Thanks Jamie....interesting.

June 10, 2008 14:56
 

Nicolas said:

Jamie,

this is very well described but if you have many columns to be validated in a data flow, you will end up with derived columns, error handling and union the data flow yet again.

messy, don't you think.

isn't there some way of doing it in a script task?

thanks,

Nicolas

October 16, 2008 10:09
 

jamie.thomson said:

Nicolas,

Messy? Perhaps...matter of opinion I guess.

I'm sure you can do it in a script component (not a script task), yeah. I'm not exactly a .Net expert but I daresay there's soem easy ways to do it. Does Datetime have a .TryParse() method?

cheers

Jamie

October 16, 2008 10:18
 

jamie.thomson said:

October 16, 2008 10:20
 

anu said:

jamie...im migrating from mysql to mssql...m using a derived colum to join  a date fiel and a time filed(both in mysql) to a single datetime field in MSsql....

m joining it as string but my output only displays the date..the time field becomes 00:00:00....

heres my derived column expression,

(DT_STR,20,1252)myDate + (DT_STR,20,1252)mytime

ive tried having havig the otput datatype as DB_datetime...DB_timestamp...string...

but all give me only the date n '00:00:00' as time

how do i solve dis? im a newbie n have been strugling 2 get by up to this stage..

can script component help in this..

thanx in advace jamie,really hope i get some help...

November 5, 2008 08:03
 

jamie.thomson said:

anu,

What is the type of the output column?

You should probably try and use the DATEPART function to extract the various parts of the dates and then concatenate them together into a string that SSIS will recognise as a datetime. The accepted formats for that string are explained in this blog entry (above).

-jamie

November 5, 2008 09:07
 

anu said:

hi jamie,

my output column is database timestamp( DT_DBtimestamp)

my table output is datetime

the thing is jamie...it outputs my date correctly but not my time...

i tried using datepart but it doest recognize d function....probably cz d input is not a datetime but time .....wat else can i do???

thanx

anu

November 12, 2008 03:07

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

Powered by Community Server (Personal Edition), by Telligent Systems