December 21, 2011 at 8:13 am
Hello,
I have a file name variable in my package. This variable holds the value something like this
data_mart_Account_2011-12-15.csv
I need to extract the date from this file name and it will be the previous date( I need to get 2011-12-14) and insert into a table. I am using a derived column transformation for this. I have given expression as
(DT_DATE)(DATEADD("D",-1,(DT_DATE)((DT_STR,100,1252)RIGHT((DT_STR,100,1252)@[User::FileName1],10))))
But it is throwing an error as
[Derived Column [1224]] Error: Casting expression "(DATEADD("D",-1,(DT_DATE)RIGHT((DT_STR,100,1252)@[User::FileName1],10)))" from data type "DT_DBTIMESTAMP" to data type "DT_DATE" failed with error code 0xC00470C5.
[Derived Column [1224]] Error: Casting expression "RIGHT((DT_STR,100,1252)@[User::FileName1],10)" from data type "DT_WSTR" to data type "DT_DATE" failed with error code 0xC00470C2.
Please assist.
Thanks
December 21, 2011 at 8:46 am
Only just scanned your code, but if you're doing a RIGHT oin the filename, remember, you have ".csv" in there. There's a lot of ways to get around this, use replace to get rid of the .csv, or try to trim it further down with like a substring, or even do a left(string, len(string)-4) and THEN do the RIGHT on top of this (sorta like RIGHT( left(yourvariable, len(yourvariable) -4), 10)
make sense?
Steve.
December 21, 2011 at 9:04 am
Yup I got it. Thanks so much for the reply. I just replaced substring in place of right and it worked.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply