SQL Server Error: Conversion failed when converting datetime from character string

Last Reply 5 months ago By pandeyism

Posted 5 months ago

 

'23.10.2016'

i want to convert this varchar type date to datetime in format yyyy-mm-dd in sql server.

when i am trying its giving error 

Conversion failed when converting datetime from character string

Posted 5 months ago

Hi iammann,

Refer below sample query.

SQL

DECLARE @TestDate AS TABLE([Date] VARCHAR(10))
INSERT INTO @TestDate VALUES('23.10.2016')
SELECT CONVERT(DATETIME,[Date],105) [Date] FROM @TestDate