日期:2014-05-18 浏览次数:20582 次
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (Id nvarchar(6),state nvarchar(4),Time datetime,AddTime int)
insert into [TB]
select '001','创建','2011-03-03 07:00:00',1 union all
select '001','删除','2011-03-04 08:07:33',3 union all
select '001','更新','2011-03-05 08:34:03',7
select * from [TB]
SELECT id,STATE,DATEADD(hh,addtime,TIME) AS TIME,addtime FROM dbo.TB
/*
id STATE TIME addtime
------ ----- ----------------------- -----------
001 创建 2011-03-03 08:00:00.000 1
001 删除 2011-03-04 11:07:33.000 3
001 更新 2011-03-05 15:34:03.000 7
(3 行受影响)*/
------解决方案--------------------
select DATEADD(hour,3,getdate())
------解决方案--------------------
dateadd日期函数。