I am trying to convert a varchar
column value into datetime
datatype, and I am not getting the expected result.
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.214') UNION ALL
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.215') UNION ALL
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.216') UNION ALL
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.217') UNION ALL
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.218') UNION ALL
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.219') UNION ALL
SELECT CONVERT(DATETIME, '2020-01-09 10:22:45.220')
I am getting the following results:
2020-01-09 10:22:45.213
2020-01-09 10:22:45.217
2020-01-09 10:22:45.217
2020-01-09 10:22:45.217
2020-01-09 10:22:45.217
2020-01-09 10:22:45.220
2020-01-09 10:22:45.220
I have tried running this code in both SSMS 2014 and 2017 with the same result. I'm not sure what I am doing wrong here...