當前位置:首頁 » 存儲配置 » 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-03-18 11:13:13 瀏覽:986
比分網源碼 發布:2025-03-18 11:00:22 瀏覽:749
不顯示腳本錯誤 發布:2025-03-18 10:58:14 瀏覽:417
網路攝像頭與伺服器怎麼搭建 發布:2025-03-18 10:51:49 瀏覽:554
java區塊鏈 發布:2025-03-18 10:35:54 瀏覽:368
私自搭建伺服器盈利違法么 發布:2025-03-18 10:32:33 瀏覽:7
os壓縮文件 發布:2025-03-18 10:26:54 瀏覽:866
安卓什麼樣的型號算是大陸國行 發布:2025-03-18 10:14:54 瀏覽:729
android添加百度地圖 發布:2025-03-18 10:05:41 瀏覽:419
音樂源碼開發 發布:2025-03-18 09:41:45 瀏覽:51