how to add datetime value and varchar value

Posted by Venky.Net under Sql Server on 9/1/2012 | Points: 10 | Views : 2494 | Status : [Member] | Replies : 3
hi
SELECT JobNo,VendorName,BillNo,BillDate,Remarks,DATEADD(day,Payment,BillDate) AS OrderPayDate from tablename

i am using this sql commnd.but i am getting the error
problem:
(1)dateadd(day,paymand,billdate)
paymand is varchar datttype
billdate is datetime

billdate paymand
22/4/2012 4
now i am adding billdate and paymand
i want result 26/4/2012
i am getting this error

Argument data type nvarchar(max) is invalid for argument 2 of dateadd function.




Responses

Posted by: Pandians on: 9/1/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Pls give some sample data!

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sureshknkt7 on: 9/1/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Venky,


Payment Data type must be integer type....

Thank you,
Suresh



Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sureshknkt7 on: 9/1/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Venky,

try this query..

Convert Payment Column Datatype from Varchar to Integer.

select DATEADD(day,Convert(int,Payment),BillDate) from Bill


Thank you,
Suresh



Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response