Opiwan
Opiwan

Reputation: 7

Conversion failed when converting the nvarchar value '2/11/2014 4:25:27 PM' to data type int

I am using a sql datasource to update a table from another table. my update query is

UPDATE    table1
SET table1.brnlimit = table2.brnlimit, table1.tellimit = table2.tellimit
FROM table1 
INNER JOIN
limit ON table1.Branch = table2.Branch AND MONTH(table1.entered) = MONTH(table2.month) AND MONTH(table1.entered) = @mo

From that datasource query itself, it runs perfectly. Updating the records by month, however when I run the website, the sqldatasource.update() call gives me the conversion failed error. I am at a loss, because I am not converting anything, just stripping out data (maybe I am wrong). At any rate, does anyone have a suggestion that may help me get past this? Thanks!

Upvotes: 0

Views: 388

Answers (1)

Tom Brown
Tom Brown

Reputation: 793

I think you need to convert the selecteddate to a datetime, then get the month

so try this ...

AND MONTH(table1.entered) = MONTH(CAST(@mo AS DATETIME))

Upvotes: 0

Related Questions