请问各位高手。。。
我想进行两个varchar字段(代表时间)的加减,谢谢!!!
------解决方案--------------------
declare @e varchar(06), @s varchar(06)
set @e= '223000 '
set @s= '213000 '
select datediff(minute, '2000-1-1 '+ ' '+substring(@s,1,2)+ ': '+substring(@s,3,2)+ ': '+substring(@s,5,2), '2000-1-1 '+ ' '+substring(@e,1,2)+ ': '+substring(@e,3,2)+ ': '+substring(@e,5,2))
------解决方案--------------------
Declare @Time1 Varchar(10), @Time2 Varchar(10)
Select @Time1 = '223549 ', @Time2 = '223849 '
Select DateDiff(mi, Cast( '1900-01-01 ' + Stuff(Stuff(@Time1, 3, 0, ': '), 6, 0 , ': ') As DateTime), Cast( '1900-01-01 ' + Stuff(Stuff(@Time2, 3, 0, ': '), 6, 0 , ': ') As DateTime))
--Result
/*
3
*/