|
Hi there, I have an SSIS package and I have this SQL query in a variable. @[User::start_date] and @[User::end_date] are two variables in the package and I can get them successfully but when it runs this query I get this error: "conversion failed when converting datetime from character string" Can you plz tell me what's wrong here? Thanks alot, SQL_user
(comments are locked)
|
|
You need to use SUBSTRING function to convert it to desired format before assigning and ISDATE() function before converting to datetime. Moreover, It will purely be dependent upon the input. If I assume the input is in YYYYMMDD format then it could be If you can tell us what kind of input you are expecting then we may lead to better approach. When I tried your suggestion I get this error: "Arithmetic overflow error converting expression to data type datetime." I think the issue is here, because when I execute it on management studio I get the error: Conversion failed when converting datetime from character string. and it points to this line set @ds='"+(DT_WSTR,30)@[User::start_date]+"' set @de='"+(DT_WSTR,30)@[User::end_date]+"' Hope you can help Thanks,
Dec 27 '11 at 03:56 AM
SQL USER
you should add ISDATE() function to validate before assigning. There is no point in assiging it before and then change it according to your LANGUAGE settings :). I have changed it a bit. But If you could let us know the details, may be we could come up with a better approach
Dec 27 '11 at 04:07 AM
Usman Butt
(comments are locked)
|

