笔记166 时间差转换
笔记166 时间差转换
1 --时间差转换 2 DECLARE 3 @dt1 datetime, 4 @dt2 datetime 5 ; 6 SELECT 7 @dt1 = '2012-07-27 11:11:00', 8 @dt2 = '2012-07-30 21:00:00' 9 ; 10 SELECT 11 diff_day = CONVERT(int, diff), 12 diff_time = CONVERT(varchar(10), diff, 108) 13 FROM( 14 SELECT 15 diff = @dt2 - @dt1 16 )AA 17 ; 18 19 SELECT diff = @dt2 - @dt1