0

Why in SQL Server if I do this:

SELECT CONVERT(datetime, '2020-06-23 23:21:22.302', 121)

I get this date:

2020-06-23 23:21:22.303
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Martin Fox
  • 33
  • 3

2 Answers2

5

see this thread

Its because datetime in SQL Server is only accurate to 3ms and will round to increments of of .000, .003, or .007 seconds

cpalmer
  • 311
  • 2
  • 9
2

Try this:

SELECT convert(datetime, '2020-06-23 23:21:22.302', 121)
SELECT convert(datetime2, '2020-06-23 23:21:22.302', 121)
SELECT convert(datetime2(3), '2020-06-23 23:21:22.302', 121)
Rodney Ellis
  • 727
  • 2
  • 13
  • 28