當前位置:首頁 » 存儲配置 » 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 14:14:18 瀏覽:227
飢荒聯機版如何自己開伺服器 發布:2025-03-18 14:04:41 瀏覽:57
9p什麼時候升級安卓 發布:2025-03-18 14:00:51 瀏覽:419
為什麼安攝像頭顯示配置沖突 發布:2025-03-18 13:59:09 瀏覽:226
安卓手機在哪裡看攔截 發布:2025-03-18 13:52:21 瀏覽:221
用伺服器怎麼掙錢 發布:2025-03-18 13:47:50 瀏覽:599
ftp自動記錄密碼失效 發布:2025-03-18 13:41:33 瀏覽:610
java泛型的方法 發布:2025-03-18 13:28:07 瀏覽:716
推薦演算法項目 發布:2025-03-18 13:15:11 瀏覽:990
androidstudio證書 發布:2025-03-18 13:15:05 瀏覽:787