可以使用cast(時間欄位asdatetime)實現;
轉換儲存過程如下:
createprocsp_millisec_2_datetime
@millisec_allbigint,
@base_timedatetime2,
@output_datetimedatetime2output
as
declare@millisec_partasbigint
declare@daysasbigint
begin
set@days=ROUND(@millisec_all/86400000,0)
set@millisec_part=@millisec_all%86400000
set@output_datetime=(SELECTDATEADD(MILLISECOND,@millisec_part,DATEADD(DAY,@days,@base_time)))
end
呼叫例,@millisec_all是毫秒數,@base_time是轉換成毫秒數的起算基本日期;
declare@output_datetimeasdatetime2
declare@millisec_allasbigint
declare@base_timeasdatetime2
set@millisec_all=86400000001
set@base_time="0001-01-0100:00:00"
execdb_tms_base.dbo.sp_millisec_2_datetime@millisec_all,@base_time,@output_datetimeout
select@output_datetime
可以使用cast(時間欄位asdatetime)實現;
轉換儲存過程如下:
createprocsp_millisec_2_datetime
@millisec_allbigint,
@base_timedatetime2,
@output_datetimedatetime2output
as
declare@millisec_partasbigint
declare@daysasbigint
begin
set@days=ROUND(@millisec_all/86400000,0)
set@millisec_part=@millisec_all%86400000
set@output_datetime=(SELECTDATEADD(MILLISECOND,@millisec_part,DATEADD(DAY,@days,@base_time)))
end
呼叫例,@millisec_all是毫秒數,@base_time是轉換成毫秒數的起算基本日期;
declare@output_datetimeasdatetime2
declare@millisec_allasbigint
declare@base_timeasdatetime2
set@millisec_all=86400000001
set@base_time="0001-01-0100:00:00"
execdb_tms_base.dbo.sp_millisec_2_datetime@millisec_all,@base_time,@output_datetimeout
select@output_datetime