當前位置:首頁 » 存儲配置 » sqlserver存儲時間

sqlserver存儲時間

發布時間: 2023-07-06 01:34:03

『壹』 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

『貳』 sqlserver 包含一個時間區間的存儲過程如何寫

create PROCEDURE ps_test
declare @id varchar(50)
as
begin
declare @from_date datetime
declare @to_date datetime
create table #tt_table (id,output_date)
select @from_date = 開始時間, @to_date = 結束時間
from A
where id = @id
while(@from_date <= @to_date)
begin
insert into #tt_table(id,output_date)
values( @id,@from_date)

DATEADD(day,1,@from_date)
end
select id, output_date
from #tt_table
end
go

熱點內容
為什麼租憑伺服器不能玩了 發布:2025-07-04 09:03:01 瀏覽:984
安卓手機減肥軟體哪個好 發布:2025-07-04 08:51:17 瀏覽:996
Oracle查看資料庫歸檔 發布:2025-07-04 08:44:53 瀏覽:608
950買什麼配置好 發布:2025-07-04 08:39:39 瀏覽:610
怎樣給應用加密 發布:2025-07-04 08:38:41 瀏覽:458
python的注釋符號 發布:2025-07-04 08:29:19 瀏覽:129
守望領域門禁密碼是多少 發布:2025-07-04 08:16:22 瀏覽:333
存儲晶元價格 發布:2025-07-04 08:16:20 瀏覽:356
大地球源碼 發布:2025-07-04 08:10:29 瀏覽:168
棋牌手游源碼 發布:2025-07-04 08:10:18 瀏覽:818