This article contains examples of converting a smalldatetime value to a datetime value in SQL Server.
The smalldatetime data type doesn’t have any fractional seconds, and its seconds component is always set to zero (:00). Its accuracy is to the nearest minute.
The datetime data type on the other hand, includes a 3-digit fractional seconds part, and its accuracy is rounded to increments of .000, .003, or .007 seconds.
When you convert a smalldatetime value to datetime, the smalldatetime value is copied to the datetime value. The fractional seconds are set to 0.
In most cases, you’d be better off converting to a datetime2 data type instead of a datetime. Doing this will provide increased accuracy, while using the same storage size. However, if you really do need it to be datetime, here are some examples.
Continue reading →