懒得写了 思路:
将2010-5-20下午 05:23:58转换为2010520172358的形式
将2010-5-20下午 05:33:58转换为2010520173358的形式
比较2010520172358与2010520173358的大小
如果 2010520172358<现在时间 then
如果 2010520172358>现在时间 then
==========这里为处在中间的代码
elseif 2010520172358<现在时间 then
==========这里为超过时间的代码
END IF
ELSEIF 2010520172358>现在时间 then
==========这里为没到时间的代码
END IF
注意 转换时间时分钟+10如果大于60要注意哦
Dim TheTime
TheTime = DateDiff("n","2010-5-20 05:23:58","2010-5-20 05:33:58")Response.Write "结果为"&TheTime&"分钟"
按分钟取时间差
直接使用 sql语句就可以了
首先建立sql函数
create function GetTimePart(@d1 datetime, @d2 datetime)
returns varchar(20)
as
begin
declare @ss bigint, @d int,@h int, @m int, @s int
set @ss = datediff(s, @d1, @d2)
set @d = @ss / ( 24 * 60 * 60 )
set @ss = @ss - @d * ( 24 * 60 * 60 )
set @h = @ss / ( 60 * 60 )
set @ss = @ss - @h * ( 60 * 60 )
set @m = @ss / 60
set @ss = @ss - @m * 60
set @s = @ss
return cast(@d as varchar)+'天'+cast(@h as varchar)+'小时'+cast(@m as varchar)+'分钟'+cast(@s as varchar)+'秒'
end
然后检索数据时使用函数。
select fbsj as 开始时间, dqsj as 结束时间, dbo.GetTimePart(fbsj, fbsj) as 结果 from 你的表
简单方便
将2010-5-20下午 05:23:58转换为2010520172358的形式
将2010-5-20下午 05:33:58转换为2010520173358的形式
比较2010520172358与2010520173358的大小
如果 2010520172358<现在时间 then
如果 2010520172358>现在时间 then
==========这里为处在中间的代码
elseif 2010520172358<现在时间 then
==========这里为超过时间的代码
END IF
ELSEIF 2010520172358>现在时间 then
==========这里为没到时间的代码
END IF
注意 转换时间时分钟+10如果大于60要注意的