sql server日期时间,在存储时怎么能让它不显示毫秒后面3个000?
存储格式更改下即可。如下:
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")。
小贴士:
此处是一个如何使用不同的DATETIME2精度值来显示不同的时间格式的示例:
PRINT @T1;
PRINT @T2; DECLARE @T0 time(0) = '16:59:11.1234567';DECLARE @T1 time(1) = '16:59:11.1234567';DECLARE @T2 time(2) = '16:59:11.1234567';DECLARE @T3 time(3) = '16:59:11.1234567';DECLARE @T4 time(4) = '16:59:11.1234567';DECLARE @T5 time(5) = '16:59:11.1234567';DECLARE @T6 time(6) = '16:59:11.1234567';DECLARE @T7 time(7) = '16:59:11.1234567';PRINT @T0;
PRINT @T3;
PRINT @T4;
PRINT @T5;
PRINT @T6;
PRINT @T7;
当运行上述代码时将会得到如下结果:
16:59:11
16:59:11.1
16:59:11.12
16:59:11.123
16:59:11.1235
16:59:11.12346
16:59:11.123457
16:59:11.1234567