日期:2014-05-17 浏览次数:20709 次
CREATE TABLE #temp (id INT, dt DATETIME)
INSERT #temp SELECT 1, '2013-08-08 12:00:00' UNION ALL SELECT 1, '2013-08-08 11:00:00'
UPDATE #temp
SET dt = DATEADD(DAY, 1, DT)
SELECT * FROM #temp
/*
id dt
1 2013-08-09 12:00:00.000
1 2013-08-09 11:00:00.000
*/
CREATE TABLE #temp (id INT, dt DATETIME)
INSERT #temp SELECT 1, '2013-08-08 12:00:00' UNION ALL SELECT 1, '2013-08-08 11:00:00'
DECLARE @YourDate DATETIME
SET @YourDate = '2013-10-1' --这个日期随便指定
UPDATE #temp
SET dt = DATEADD(DAY, DATEDIFF(DAY, DT, @YourDate), DT)
SELECT * FROM #temp
/*
id dt
1 2013-10-01 12:00:00.000
1 2013-10-01 11:00:00.000
*/