更新时间:2022-03-04 01:26:27
使用time(7)
作为您的数据类型
-Eduard
Usetime(7)
as your datatype
-Eduard
无论您存储在SQL Server的DateTime字段(或.NET本身)中的任何内容,都存储为自任意起点以来的毫秒数.除非将其存储为字符串值(这是一个非常糟糕的主意),否则它将始终具有秒数的小数部分.独自留下来:在显示数据时处理人类可读的转换,不要试图删除信息以使其以后更容易显示-它行不通,只会使事情变得更糟!
Whatever you store in a DateTime field in SQL server (or .NET itself) is stored as a number of milliseconds since an arbitrary start point. Unless you store it as a string value (and that is a very bad idea), it will always have a decimal component to the seconds. Leav it alone: and handle human readable conversions when you display the data, do not try to remove information to make it simpler to display later - it won''t work, it will just make things worse!
在数据库中添加为字符串
In Database Add as string
obj.logintime=DateTime.Now.ToShortTimeString()