December 11, 2009 at 1:56 am
Hi,
I am getting the date in flat file like this 12102009 and i want to save the date which is in datetime format in database. Here while importing into the database i am using derived column to convert the date column into datetime format.
Can any one help me how to convert the date(12102009) into datetime format(12/10/2009) using derived column editor.
Thanks,
Jags
December 11, 2009 at 7:03 am
Is the value coming across as a string or an integer?
I'd do string manipulation. If it is an integer convert to string, then use the substring function to parse out the 3 parts of the data and put the "/" between. Then convert the concatenated string to Date.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 11, 2009 at 7:03 am
[font="Comic Sans MS"]
Hey Jags -
Not sure which one is your dd and which one is mm from your example 😛
Anyway here you go:
(DT_DBTIMESTAMP)(SUBSTRING((DT_WSTR,8)MyStringDate,1,4) +
"/" + SUBSTRING((DT_WSTR,8)MyStringDate,5,2)
+ "/" + SUBSTRING((DT_WSTR,8)MyStringDate,7,2))
oops: cross posted with Jack 😎 .. the code will work if it's string ... else you would need to convert ..
[/font]
[font="Comic Sans MS"]--
Sabya[/font]
December 11, 2009 at 7:10 am
Hi,
Thanks for your response and it is working fine. Thanks a lot.
Thanks,
jags
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply