I learned this lesson and thought that the difference between smalldatetime and datetime is only in the time range:
The valid time range of smalldatetime is ~ 2079/6/6
The valid time range of datetime is 1753/1/1 ~ 9999/12/31
So I decided that smalldatetime would be used if the value does not have to be too far from the date range.
But I ignore the more important difference, that isSmalldatetime is accurate to minutes, while datetime is accurate to 3.33 milliseconds.
Therefore, when I saved the data in seconds after 00, I found that it was originally caused by smalldatetime. After I changed the data type to datetime, the data in seconds can be stored normally.
**************************************** **************************************** *********
In SQL Server, smalldatetime can only be accurate to minutes, while datatime can be precise to 3% seconds (3.33 milliseconds ).
Smalldatetime usage4The first two bytes store the base date (January 1, January 1, 1900)AfterThe number of days. The last two bytes are stored after midnightMinutes.
Datetime usage8The first four bytes store the base date (January 1, 1900)BeforeOrAfterThe number of days, the last four bytes are stored after midnightMilliseconds.
Since the precision of datetime is 3% seconds, this involves decimal places. It can be a colon or a decimal point before milliseconds. It indicates the meaning of the colon at the same time, and 11: 11: 11: 21 indicates021Milliseconds. The preceding 0 is omitted, while the decimal point indicates the mathematical decimal point, for example, 11:11:11. 21.210Milliseconds. The value is omitted from the following 0.