The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value
I want to a take the substring of a value in a column " 2010-11-10 11:59:00" to "2010-11-10":
SELECT CONVERT(DATETIME, SUBSTRING(CONVERT(VARCHAR(15), CONVERT(DATETIME, export_date, 105)),0,15),101)
FROM TABLE
I have written the fo开发者_开发百科llowing query, but it is not resulting this error:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Try something like
SELECT DATEADD(dd,0, DATEDIFF(dd,0,CONVERT(DATETIME, '2010-11-10 11:59:00',101)))
Output
2010-11-10 00:00:00.000
SELECT substring(convert(varchar(15),convert(varchar(15), export_date, 105)),0,11) from
精彩评论