updating Error

Copper Contributor

update Database.dbo.tbl_Traditional_OR
set EntryDate=CONVERT(datetime, substring(BillNo,5,12), 112)
Where EntryDate is null

 

i found below error

Msg 241, Level 16, State 1, Line 19
Conversion failed when converting date and/or time from character string.

please help me. i am a fresher. i am using sql server 2014

2 Replies

@gkibria29 

 

Change substring(BillNo,5,12) to substring(BillNo,5,8) and try again.

If still fail, please post result of this SQL

 

SELECT BillNo
FROM Database.dbo.tbl_Traditional_OR
WHERE EntryDate IS NULL

 

 


Conversion failed when converting date and/or time from character string.

@gkibria29 then your source data contains a not-convertable string.

Have you some sample data for us?