October 26, 2012 at 1:15 pm
Hi friends ,
I have a variable called : Today .I am assigning the value : getdate() to it.
When i am doing so , I am getting the below error.
The data types "DT_WSTR" and "DT_DATE" are incompatible for binary operator "+".
The operand types could not be implicitly cast into compatible types for the operation.
To perform this operation, one or both operands need to be explicitly cast with a cast operator.
I am using the today date in my query as below:
"SELECT
I014A_ACCT
, IMPORT_DATE = '"+ @[User::Today] +"'
FROM dbo.DB014 WITH (NOLOCK)
WHERE COPYDATE = '"+ @[User::CopyDate] +"'"
Could any one tell how to solve this error?? please?
Thanks,
Komal
November 9, 2012 at 8:28 pm
komal145 (10/26/2012)
Hi friends ,I have a variable called : Today .I am assigning the value : getdate() to it.
When i am doing so , I am getting the below error.
The data types "DT_WSTR" and "DT_DATE" are incompatible for binary operator "+".
The operand types could not be implicitly cast into compatible types for the operation.
To perform this operation, one or both operands need to be explicitly cast with a cast operator.
I am using the today date in my query as below:
"SELECT
I014A_ACCT
, IMPORT_DATE = '"+ @[User::Today] +"'
FROM dbo.DB014 WITH (NOLOCK)
WHERE COPYDATE = '"+ @[User::CopyDate] +"'"
Could any one tell how to solve this error?? please?
Thanks,
Komal
Try the expression like this:
"SELECT
I014A_ACCT
, IMPORT_DATE = '"+ (DT_WSTR, 4) YEAR( @[User::Today] ) + "-" +
Right("0"+ (DT_WSTR, 2) MONTH( @[User::Today] ) ,2) + "-" +
Right("0"+ (DT_WSTR, 2) DAY( @[User::Today] ) ,2)
+"'
FROM dbo.DB014 WITH (NOLOCK)
WHERE COPYDATE = '"+ @[User::CopyDate] +"'"
As an aside, what's the deal with using NOLOCK? Are you aware of the downfalls of using that hint?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply